AzureFeaturedPower Shell

Manage Azure WVD Hostpools – Cmdlets PS

Azure Windows Virtual Desktop

If you have deployed Azure WIndows Virtual Desktop to your azure environment and not using any managment tools to manage them, then you can use the following PowerShell cmdlets.

 

################################################
### Get more Cmdlts for WVD  ###################################
############   https://docs.microsoft.com/en-us/powershell/module/windowsvirtualdesktop/ #######################


############################################################
### Login
Add-RdsAccount -DeploymentUrl "https://rdbroker.wvd.microsoft.com" 

$tenant = 'Host Pool Tenant Name'
$appGroupName = 'Desktop Application Group'
$hostPool = 'name of your hostpool'



###################################################
### Get User Session details
Get-RdsUserSession -TenantName $tenant -HostPoolName $hostPool
Get-RdsUserSession -TenantName $tenant -HostPoolName $hostPool | select SessionHostName, UserPrincipalName, HostPoolName, SessionState | ft -AutoSize


###################################################
#get list of current wvd session
Get-RdsSessionHost -TenantName $tenant -HostPoolName $hostPool | select SessionHostName, Status | ft



###################################################
#get specific hostpools details
Get-rdsHostpool -TenantName $tenant -hostpool $hostPool


###################################################
### Get SessionHost details
Get-RdsSessionHost -TenantName $tenant -HostPoolName $hostPool
Get-RdsSessionHost -TenantName $tenant -HostPoolName $hostPool | select SessionHostName, HostPoolName, AllowNewSession, Sessions, Status | ft





###################################################
### Get HostPools Details
Get-RdsHostPool -TenantName $tenant | ft
Get-RdsHostPool -TenantName $tenant | select HostPoolName, Persistent, MaxSessionLimit | ft


####################################################################################
#Add users to Desktop Application Group
Get-RdsAppGroupUser -TenantName $tenant -HostPoolName $hostPool -AppGroupName $appGroupName | select UserPrincipalName  'username@domain.com'
Get-RdsAppGroupUser -TenantName $tenant -HostPoolName $hostPool -AppGroupName $appGroupName

#Add-RdsAppGroupUser -TenantName $tenant -HostPoolName $hostPool -AppGroupName $appGroupName -UserPrincipalName username@domain.com






###############################################################################
#App Group"
Get-RdsRemoteApp -TenantName $tenant -HostPoolName $hostPool -AppGroupName $appGroupName
Get-RdsAppGroupUser  -TenantName $tenant -HostPoolName $hostPool -AppGroupName $appGroupName
Get-RdsAppGroupUser  -TenantName $tenant -HostPoolName $hostPool -AppGroupName $appGroupName| ? UserPrincipalName -eq username@domain.com

Get-RdsAppGroupUser -TenantName $tenant -HostPoolName $hostPool -UserPrincipalName username@domain.com



############################################
#Diagnostics"

Get-RdsDiagnosticActivities -TenantName $tenant -UserName username@domain.com -Detailed
Get-RdsDiagnosticActivities -TenantName $tenant
Get-RdsDiagnosticActivities -TenantName $tenant -Outcome Failure

(Get-RdsDiagnosticActivities -TenantName $tenant -username username@domain.com -detailed).Errors
Get-RdsDiagnosticActivities -TenantName $tenant -username
(Get-RdsDiagnosticActivities -TenantName $tenant -username username@domain.com -ActivityId -detailed).Errors
(Get-RdsDiagnosticActivities -TenantName $tenant -username username@domain.com’ -detailed).Errors

Get-RdsDiagnosticActivities -TenantName $tenant -ActivityType Connection -StartTime 03/15/2020 -UserName username@domain.com
Get-RdsDiagnosticActivities -TenantName $tenant -UserName username@domain.com -StartTime "08/01/2018"

Get-RdsDiagnosticActivities -TenantName $tenant -UserName username@domain.com -ActivityType Connection

Get-RdsDiagnosticActivities -TenantName $tenant -Outcome Failure




###############################################################################
#Roles
Get-RdsRoleAssignment –SignInName username@domain.com -TenantName $tenanat -HostPoolName $hostPool
#New-RdsRoleAssignment -RoleDefinitionName 'RDS Operator' -SignInName username@domain.com -TenantName $tenanat -HostPoolName $hostPool -AppGroupName 'Desktop Application Support'
Get-RdsRoleAssignment -SignInName username@domain.com
Get-RdsRoleAssignment 



###############################################################################
#         Find Licnese session vm                                           #
# https://docs.microsoft.com/en-us/azure/virtual-desktop/apply-windows-license
get-azvm -ResourceGroupName resourceGroupName  -Name vmname
get-azvm -ResourceGroupName resourceGroupName -Name vmname| select Name, Type, LicenseType


#######################################################
# Export current registration Token
$token = (Export-RdsRegistrationInfo -TenantName $tenant -HostPoolName $hostPool).Token

 

Show More
Back to top button