This is a blogpost about a script which initiates a logoff for all users in a WVD Hostpool via Powershell. The script populates the hostpool(s) based on a Resource Group within Azure. If there are multiple hostpools within this Resource Group the users are logged off also.

Script Syntaxis

This is the syntax for the script. Below I will show an example of the script.

Example

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:

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:

First, .
Second, the name of the hostpool and sessionhost are shown.
After that, a “While Loop” waits for all the users to logoff.
The line “There are still 1 user(s) on WVDDEVRel67 logged on” keeps track of the while loop. Every 10 seconds this runs again.

NOTE: Users are logged off immediately. There is no warning. This is what the user sees:

Log off message

And that’s how you logoff users via Powershell on a WVD Hostpool.

References

Microsoft Docs about WVD CMDlets

Set Drain Mode Powershell

Related Posts