How to delete a Windows Virtual Desktop (WVD) Tenant
With all the new changes coming to WVD, you may end up in a situation where you’d like to delete an old WVD Tenant. For example – the original WVD Tenant we use for Device Advice was created using PowerShell scripts (at the time there was no “pane” for WVD in the Azure Portal). This tenant doesn’t show up as a host pool in the new WVD pane, unfortunately. I prefer to manage through the Azure Portal when possible, so let’s delete that old tenant!
First – we’ll need to open up a PowerShell Admin console and run the following commands:
import-module AZ import-module Microsoft.RdInfra.RDPowerShell Add-RdsAccount -DeploymentUrl "https://rdbroker.wvd.microsoft.com"
Sign in with the admin account that created the tenant. This will let us connect to our WVD instance:
Great! Before we can delete the tenant, we’ll first need to remove any session hosts. To get the information we’ll need on those session hosts, run:
Get-RdsSessionHost -TenantName "tenantname" -HostPoolName "hostpoolname"
(If you don’t know your Tenant name, you can also run “Get-RdsTenant”):
(And if you don’t know your Host Pool name, run “Get-RdsHostPool -tenantname “thenamefromthepreviouscommand” “)
Then run the following command (notice in the screenshot that I needed to add force, because a user session still exists):
Remove-RdsSessionhost -TenantName "tenantname" -HostPoolName "HostPool" -Name "nameofsessionhost" -force
Working our way up, now we’ll need to delete the App Group that the Host Pool is in. Run the following command:
Remove-RdsAppGroup -tenantName "tenantname" -HostPoolName "hostpoolname" -Name "appgroupname"
Which means it’s time to delete the Host Pool:
Remove-RdsHostPool -tenantName "tenantname" -name "hostpoolname"
And now we can finally delete the tenant!
Remove-RdsTenant -name "tenantname"
Since the tenant is deleted, be sure to go to the Azure portal and delete the associated resource group. That way you’re not spending any money on resources that no one can access:
And that’s all! We’ve successfully deleted an old WVD tenant. 🎪