This is a blogpost about a script which initiates a delete request for all resources in a Resource Group, I use this script for deleting WVD hostpools with Powershell.

The hostpool resource need to be deleted in an exact order.
1. VM’s need to be deleted first.
2. After that sessionhosts must delete from the hostpool.
3. Then all the resource except for the hostpool are deleted.
4. Lastly, the hostpool is deleted.

Script Syntaxis

This is the syntaxis for the script. In addition, please remember to edit the array “$ResourceGroupname”.


Firstly, check whether you have correct Powershell modules installed. Use the following code to do so:

Secondly, you need to connect to Azure Powershell. You can do so by using the following command:

Firstly, save the script syntaxis as a .ps1 file. After that, open up Powershell and browse to the location where you placed the script.

Now it’s time to run the script. Save the script as a ps1 file and run it:

This is the output for the script. As you can see the order mentioned in the first paragraph is shown:

WVD Powershell delete script output

And that is how you delete WVD hostpools with a Powershell script!


My other WVD scripts:

Logoff Users from a WVD Hostpool
Set Drain Mode on a WVD Hostpool

Microsoft Docs about WVD Powershell

Related Posts