question

TanmoyBanerjee-1098 avatar image
0 Votes"
TanmoyBanerjee-1098 asked AmitaMenon-3691 edited

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

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.

remote-desktop-servicesazure-virtual-desktop
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@TanmoyBanerjee-1098 Any update on issue?

Please "Accept as Answer" if it helped so it can help others in community looking for help on similar topics.

Thanks



0 Votes 0 ·
LeilaKong-MSFT avatar image
0 Votes"
LeilaKong-MSFT answered TanmoyBanerjee-1098 commented

Hello @TanmoyBanerjee-1098 ,

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://docs.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://docs.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.









· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

95913-existingvdiaddingerror.jpg



Thanks for your reply Leila!
I got answer for removing VM from Hyper-v and failover cluster but not for adding existing vm to existing VDI collection. Which link you provided there it's mentioned that it's not possible. Please find attached artifacts.
Please let me know, if there are any other workaround.

0 Votes 0 ·
LeilaKong-MSFT avatar image
0 Votes"
LeilaKong-MSFT answered

Hello @TanmoyBanerjee-1098 ,

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://docs.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://docs.microsoft.com/en-us/powershell/module/remotedesktop/add-rdvirtualdesktoptocollection?view=windowsserver2016-ps


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

LeilaKong-MSFT avatar image
0 Votes"
LeilaKong-MSFT answered

Hello @TanmoyBanerjee-1098 ,

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

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.