1. Home
  2. PowerShell – Remove-AzWvdUserSession Command

PowerShell – Remove-AzWvdUserSession Command

WVD is a new technology being offered by Microsoft and while there is a good set of PowerShell commands to complement it, there isn’t a lot of info regarding them. This is an example of the command you can issue to remove one user from a hast without needing to log in yourself to remove them, or have to kick everyone off using the Azure Portal “logout all users” function.

Fist thing first we need to connect our account to the Az module by running this command.


Next, we need to get our users Session Host and Session ID. We can do that with the Get-AzWvdUserSession

Get-AzWvdUserSession -ResourceGroupName AZ-MNT-WVD-RG -HostPoolName AZ-MNT-WVD-HOSTPOOL -SubscriptionId <This is found on the Azure portal under Subscriptions> | select UserPrincipalName, Name

Session Host will look like this – AZ-MNT-WVD1.ad.local with WVD# being the server they are currently connected to.

Lastly, once we have the Session Host and Session ID we can run the Remove-AzWvdUserSession

Remove-AzWvdUserSession -ResourceGroupName AZ-MNT-WVD-RG -HostPoolName AZ-MNT-WVD-HOSTPOOL -SessionHostName <This is found using Get-AzWvdUserSession> -Id <This is found using Get-AzWvdUserSession>

Leave a Comment