Skip to content

Instantly share code, notes, and snippets.

@OmerMicrosoft
Created April 23, 2019 10:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OmerMicrosoft/103b55927faca6fbd642d1633c34be96 to your computer and use it in GitHub Desktop.
Save OmerMicrosoft/103b55927faca6fbd642d1633c34be96 to your computer and use it in GitHub Desktop.
Display the RDS users of a specific hostpool in a Windows Virtual Desktop tenant. Let you add additional RDS users to a hostpool if required.
#Get Azure admin credentials
Write-Host "Getting Azure credentials... "
$Credentials = Get-Credential -Message "Enter your Azure admin credentials"
#Add RDS Account in order to be able to change WVD configuration
$BrokerURL = "https://rdbroker.wvd.microsoft.com"
Write-Host "Adding the RDS account... " -NoNewline
Try {
Add-RdsAccount -DeploymentUrl $BrokerURL -Credential $Credentials -ErrorAction Stop | Out-Null
}
Catch {
Write-Host "Failed to add the RDS account. Aborting." -ForegroundColor Red
Break
}
Write-Host "Done." -ForegroundColor Green
#Select WVD tenant
Write-Host "Getting WVD tenants information... " -NoNewline
Try {
$RDSTenantName = (Get-RdsTenant).TenantName | Out-GridView -Title "Please select one WVD tenant from the list above" -OutputMode Single -ErrorAction Stop
}
Catch {
Write-Host "Failed to get WVD tenant information. Aborting." -ForegroundColor Red
Break
}
Write-Host "Done." -ForegroundColor Green
#Select WVD hostpool within the tenant
Write-Host "Getting WVD hostpools information... " -NoNewline
Try {
$RDSHostPoolName = (Get-RdsHostPool -TenantName $RDSTenantName).HostPoolName | Out-GridView -Title "Please select one hostpool from the list above" -OutputMode Single -ErrorAction Stop
}
Catch {
Write-Host "Failed to get WVD hostpools information. Aborting." -ForegroundColor Red
Break
}
Write-Host "Done." -ForegroundColor Green
#Display current RDS users in the selected hostpool
Write-Host "Getting WVD users information for $RDSHostPoolName in $RDSTenantName..."
$RDSUsers = Get-RdsAppGroupUser -TenantName $RDSTenantName -HostPoolName $RDSHostPoolName -AppGroupName "Desktop Application Group" | Select UserPrincipalName
Write-Host $RDSUsers.UserPrincipalName
#Add additional RDS users
Write-Host "###################################" -ForegroundColor Yellow
$Answer = Read-Host "Press 'Y' if you would like to add additional RDS users to your hostpool"
While ($Answer -ieq "Y") {
$UserToAdd = Read-Host "Enter the user UPN (e.g. User@contoso.com)"
try {
Add-RdsAppGroupUser -TenantName $RDSTenantName -HostPoolName $RDSHostPoolName -AppGroupName "Desktop Application Group" -UserPrincipalName $UserToAdd
}
Catch {
Write-Host "Failed to add user to the hostpool." -ForegroundColor Red
Break
}
Write-Host "Succesfully add $UserToAdd to hostpool $RDSHostPoolName" -ForegroundColor Green
$Answer = Read-Host "Press 'Y' if you would like to add additional RDS users to your hostpool"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment