How to add existing virtual desktop to RDS collection or remove vdi which are not in collection

Tanmoy Banerjee 36 Reputation points
2021-05-10T19:58:05.13+00:00

Get-rdvirtualdesktop command showing few VDIs where their provisioning status is showing either failed or unknown. Then I manually checked those vms, they are not in RDS Collection then how those VDIs are showing in the output of the command?
I found those VDIs are in Hyper-V and Failover Cluster roles but not in RDS Collection.
How do I permanently delete those VDIs from RDS collection? or can I re add those VDIs in Collection?
Is there any script or cmdlet by which I can delete VMs from Failover Cluster, Hyper-V, RDS Collection and can delete its all associated files & folders from CSV.

Azure Virtual Desktop
Azure Virtual Desktop
A Microsoft desktop and app virtualization service that runs on Azure. Previously known as Windows Virtual Desktop.
1,432 questions
Remote Desktop
Remote Desktop
A Microsoft app that connects remotely to computers and to virtual apps and desktops.
4,371 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Leila Kong 3,696 Reputation points
    2021-05-11T02:22:34.587+00:00

    Hello @Tanmoy Banerjee ,

    1.Did you use below command to retrieve a list of Virtual Desktops in a Collection:
    Get-RDVirtualDesktop -ConnectionBroker "rdcb.contoso.com" -CollectionName @("Virtual Desktop pool")
    https://learn.microsoft.com/en-us/powershell/module/rdmgmt/get-rdvirtualdesktop?view=windowsserver2019-ps

    2.You may delete it manually: Open Failover Cluster Manager, then click on Roles, you should see list of VM’s, select the one you want to delete, then right on it and select Remove. Then go to Hyper-V host where VM was running from, so you can remove from list. Then it’s time to delete the VM disk, by going to the location you looked at before you deleted the VM.
    How to delete old VM from Hyper-V Cluster : https://howtohelpdesk.com/how-to-delete-old-vm-from-hyper-v-cluster/

    3.It is also possible to build a PowerShell script to delete and remove both virtual machines and its virtual hard disks.
    REMOVE VIRTUAL MACHINES AND VIRTUAL HARD DISKS COMPLETELY WITH POWERSHELL : https://techgenix.com/remove-virtual-machines/

    Other references:
    Add-RDVirtualDesktopToCollection : https://learn.microsoft.com/en-us/powershell/module/remotedesktop/add-rdvirtualdesktoptocollection?view=windowsserver2016-ps
    How to Delete a Virtual Hard Disk From Hyper-V Cluster Shared Volume : https://www.techsupportpk.com/2016/11/how-to-delete-virtual-hard-disk-from-hyperv-cluster-shared-volume.html
    Can't add existing VM to RDS Collection (Server 2012) : https://social.technet.microsoft.com/Forums/windowsserver/en-US/ba70044c-c904-4359-aed8-9c34fd94c0de/cant-add-existing-vm-to-rds-collection-server-2012?forum=winserverTS
    Add virtual desktop to existing RDS VDI collection : https://social.technet.microsoft.com/Forums/lync/en-US/27fd1a49-d593-4ab4-86bc-db2b409c8b6b/add-virtual-desktop-to-existing-rds-vdi-collection?forum=winserverTS

    Best regards,
    Leila


    If the Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. Leila Kong 3,696 Reputation points
    2021-05-13T07:00:18.753+00:00

    Hello @Tanmoy Banerjee ,

    1.Please make sure the VM you are attempting to add is not running.
    2.What's the result if you enter: Get-RDVirtualDesktopCollection command?
    https://learn.microsoft.com/en-us/powershell/module/remotedesktop/get-rdvirtualdesktopcollection?view=windowsserver2016-ps
    3.Based on below post with the same error message: you cannnot add an existing VM to a managed pool. You need to tell it how many to create and how to allocate them and it will create new VMs based on the template and add them to the collection. Maybe "Could try saving the existing vhdx, creatin some additions to the pool and then dropping the file in place and re-attaching". https://social.technet.microsoft.com/Forums/lync/en-US/27fd1a49-d593-4ab4-86bc-db2b409c8b6b/add-virtual-desktop-to-existing-rds-vdi-collection?forum=winserverTS
    4.Have a try with the following command:
    Add-RDVirtualDesktopToCollection -ConnectionBroker "rdcb.contoso.com" -CollectionName "Virtual Desktop Pool" -VirtualDesktopAllocation @{"RDS-WKS-A27.vdi.contoso.com"=1;"RDS-WKS-A28.vdi.contoso.com"=2} -VirtualDesktopPasswordAge 31
    This command adds virtual desktops to the managed pooled virtual desktop collection named Virtual Desktop Pool that is associated with the RD Connection Broker server named rdcb.contoso.com. The VirtualDesktopAllocation parameter specifies that one virtual desktop is created on the host servers named RDS-WKS-A27.vdi.contoso.com and two virtual desktops are created on the host server named RDS-WKS-A28.vdi.contoso.com. The command specifies that after 31 days the server enforces a password update for the virtual desktops.
    https://learn.microsoft.com/en-us/powershell/module/remotedesktop/add-rdvirtualdesktoptocollection?view=windowsserver2016-ps

    0 comments No comments

  3. Leila Kong 3,696 Reputation points
    2021-05-27T07:37:23.573+00:00

    Hello @Tanmoy Banerjee ,

    Just checking in to see if the information provided was helpful.
    Please post back at your convenience if we can assist further.

    0 comments No comments