I am working on a script which deals with leavers, and as part of it, it should remove the Virtual Desktop Assignment of the user. The script is executed from a remote server, and in this part it should "ask" the connection broker server to remove the assignment of the user.
I made sure that all the parameters are the same, and Get-RDPersonalVirtualDesktopAssignment shows the test user has a vdi assigned. But Remove-RDPersonalVirtualDesktopAssignment in turn tells me : "Remove-RDPersonalVirtualDesktopAssignment : User is not assigned any personal virtual desktop in this collection."
Any thoughts on what am I missing here would be much appreciated, as it is driving me nuts :(
Clear-Host
Import-Module RemoteDesktop
$cb = "<connectionBrokerServer>
$colection = "<collectionName>"
$user = "<DOMAIN\User>"
Write-Host -ForegroundColor Cyan "Locating VDI assignment for $user"
Get-RDPersonalVirtualDesktopAssignment -ConnectionBroker $cb `
-CollectionName (Get-RDVirtualDesktopCollection $colection -ConnectionBroker $cb).CollectionName `
-User $user
Write-Host -ForegroundColor Cyan "Removing VDI assignment of $user"
Remove-RDPersonalVirtualDesktopAssignment -ConnectionBroker $cb `
-CollectionName (Get-RDVirtualDesktopCollection $colection -ConnectionBroker $cb).CollectionName `
-User $user `
-WhatIf
I don't use this so can't test myself, but will it allow you to pipe the "Get" result to the remove command? e.g.