Today I want to show you how to configure Device redirections for your Azure Virtual Desktop environment using PowerShell and Azure CLI. Given that several properties and different configurations are possible, I divided the information in 2 articles.
A first article will demonstrate how to configure the RDP properties for Audio and Video Redirection, and a second post will show you how to setup RDP properties for local devices and resources redirection. OK, let’s go.
Azure PowerShell Workaround
First, you need to ensure the Az.DesktopVirtualization module is installed on your computer and imported into your Powershell session. To do that, you should use the following commands.
1 2 3 4 | Install-Module Az.DesktopVirtualization Import-Module Az.DesktopVirtualization |
Once you’ve imported the module, you’re ready to go. The easiest way to get started is to log in interactively at the command line.
1 2 3 | Connect-AzAccount |
This cmdlet will bring up a dialog box prompting you for your email address and password associated with your Azure account.
You can choose the default subscription if you have more than one associated with your mail account. To perform this task, we will use the following commands:
1 2 3 4 | Get-AzSubscription Select-AzSubscription -Subscription "My Subscription" |
Once you set your default subscription, you’re ready to start.
Set the variables
Here, we define the characteristics of our environment and the resource’s properties.
1 2 3 4 | $resourceGroupName="RG-DEMO-WE" $hostPoolName="HP-DEMO-WE" |
Define RDP properties for AV redirection
To set a custom RDP property, you should use the Update-AzWvdHostPool cmdlet.
Microphone redirection
This setting determines how sounds captured (recorded) on the local computer are handled when connected to the remote computer. These are the accepted values.
- audiocapturemode:i:0 – Disable audio capture from the local device.
1 2 3 4 5 | Update-AzWvdHostPool -Name $hostPoolName ` -ResourceGroupName $resourceGroupName ` -CustomRdpProperty "audiocapturemode:i:0" |
- audiocapturemode:i:1 – Enable audio capture from the local device and redirection to an audio application in the remote session.
1 2 3 4 5 | Update-AzWvdHostPool -Name $hostPoolName ` -ResourceGroupName $resourceGroupName ` -CustomRdpProperty "audiocapturemode:i:1" |
Redirect video encoding
- encode redirected video capture:i:0 – Disable encoding of redirected video.
1 2 3 4 5 | Update-AzWvdHostPool -Name $hostPoolName ` -ResourceGroupName $resourceGroupName ` -CustomRdpProperty "encode redirected video capture:i:0" |
- encode redirected video capture:i:1 – Enable encoding of redirected video.
1 2 3 4 5 6 | Update-AzWvdHostPool -Name $hostPoolName ` -ResourceGroupName $resourceGroupName ` -CustomRdpProperty "encode redirected video capture:i:1" |
Encoded video quality
This setting controls the quality of the encoded video. These are the accepted values.
- quality:i:0 – High compression video.
1 2 3 4 5 | Update-AzWvdHostPool -Name $hostPoolName ` -ResourceGroupName $resourceGroupName ` -CustomRdpProperty "redirected video capture encoding quality:i:0" |
- quality:i:1 – Medium compression video.
1 2 3 4 5 | Update-AzWvdHostPool -Name $hostPoolName ` -ResourceGroupName $resourceGroupName ` -CustomRdpProperty "redirected video capture encoding quality:i:1" |
- quality:i:2 – Low compression video with high picture quality.
1 2 3 4 5 | Update-AzWvdHostPool -Name $hostPoolName ` -ResourceGroupName $resourceGroupName ` -CustomRdpProperty "redirected video capture encoding quality:i:2" |
Audio output location
- audiomode:i:0 – Play sounds on the local computer
1 2 3 4 5 | Update-AzWvdHostPool -Name $hostPoolName ` -ResourceGroupName $resourceGroupName ` -CustomRdpProperty "audiomode:i:2" |
- audiomode:i:1 -Play sounds on the remote computer.
1 2 3 4 5 | Update-AzWvdHostPool -Name $hostPoolName ` -ResourceGroupName $resourceGroupName ` -CustomRdpProperty "audiomode:i:1" |
- audiomode:i:2 -Do not play sounds.
1 2 3 4 5 | Update-AzWvdHostPool -Name $hostPoolName ` -ResourceGroupName $resourceGroupName ` -CustomRdpProperty "audiomode:i:0" |
Define multiple custom RDP properties
To set multiple custom RDP properties, you should use the Update-AzWvdHostPool cmdlet with the following syntax.
1 2 3 4 5 | Update-AzWvdHostPool -Name $hostPoolName ` -ResourceGroupName $resourceGroupName ` -CustomRdpProperty "audiocapturemode:i:0;encode redirected video capture:i:0;redirected video capture encoding quality:i:0;audiomode:i:0" |
And verify your changes with the Get-AzWvdHostPool cmdlet.
1 2 3 4 | Get-AzWvdHostPool -Name $hostPoolName ` -ResourceGroupName $resourceGroupName | format-list Name, CustomRdpProperty |
Reset all custom RDP properties
If you want to reset all custom RDP properties, you should use the Update-AzWvdHostPool cmdlet with the following syntax.
1 2 3 4 5 | Update-AzWvdHostPool -Name $hostPoolName ` -ResourceGroupName $resourceGroupName ` -CustomRdpProperty "" |
Azure CLI Workaround
In this case, we will use Azure Cloud Shell, a browser-based shell built into Azure Portal. This allows us to use the Azure command-line tools (Azure CLI and Azure PowerShell) directly from a browser. If you want to know more about Azure Cloud Shell, check out this link.
First, we define the characteristics of our environment and store the values in variables.
1 2 3 4 | resourceGroupName="RG-DEMO-WE" hostPoolName="HP-DEMO-WE" |
Define RDP properties for AV redirection
To set a custom RDP property, you should use the following command.
Microphone redirection
- audiocapturemode:i:0 – Disable audio capture from the local device.
1 2 3 4 5 | az desktopvirtualization hostpool update --name $hostPoolName \ --resource-group $resourceGroupName \ --custom-rdp-property "audiocapturemode:i:0" |
- audiocapturemode:i:1 – Enable audio capture from the local device and redirection to an audio application in the remote session
1 2 3 4 5 | az desktopvirtualization hostpool update --name $hostPoolName \ --resource-group $resourceGroupName \ --custom-rdp-property "audiocapturemode:i:1" |
Redirect video encoding
- encode redirected video capture:i:0 – Disable encoding of redirected video.
1 2 3 4 5 | az desktopvirtualization hostpool update --name $hostPoolName \ --resource-group $resourceGroupName \ --custom-rdp-property "encode redirected video capture:i:0" |
- encode redirected video capture:i:1 – Enable encoding of redirected video
1 2 3 4 5 | az desktopvirtualization hostpool update --name $hostPoolName \ --resource-group $resourceGroupName \ --custom-rdp-property "encode redirected video capture:i:1" |
Encoded video quality
- quality:i:0 – High compression video.
1 2 3 4 5 | az desktopvirtualization hostpool update --name $hostPoolName \ --resource-group $resourceGroupName \ --custom-rdp-property "redirected video capture encoding quality:i:0" |
- quality:i:1 – Medium compression video.
1 2 3 4 5 | az desktopvirtualization hostpool update --name $hostPoolName \ --resource-group $resourceGroupName \ --custom-rdp-property "redirected video capture encoding quality:i:1" |
- quality:i:2 – Low compression video with high picture quality.
1 2 3 4 5 | az desktopvirtualization hostpool update --name $hostPoolName \ --resource-group $resourceGroupName \ --custom-rdp-property "redirected video capture encoding quality:i:2" |
Audio output location
- audiomode:i:0 – Play sounds on the local computer.
1 2 3 4 5 | az desktopvirtualization hostpool update --name $hostPoolName \ --resource-group $resourceGroupName \ --custom-rdp-property "audiomode:i:0" |
- audiomode:i:1 -Play sounds on the remote computer.
1 2 3 4 5 | az desktopvirtualization hostpool update --name $hostPoolName \ --resource-group $resourceGroupName \ --custom-rdp-property "audiomode:i:1" |
- audiomode:i:2 -Do not play sounds.
1 2 3 4 5 6 | az desktopvirtualization hostpool update --name $hostPoolName \ --resource-group $resourceGroupName \ --custom-rdp-property "audiomode:i:2" |
Define multiple custom RDP properties
To set multiple custom RDP properties, you should use the following command.
1 2 3 4 5 | az desktopvirtualization hostpool update --name $hostPoolName \ --resource-group $resourceGroupName \ --custom-rdp-property "audiocapturemode:i:0;encode redirected video capture:i:0;redirected video capture encoding quality:i:0;audiomode:i:0" |
And verify your changes with the following command.
1 2 3 4 5 | az desktopvirtualization hostpool show --name $hostPoolName \ --resource-group $resourceGroupName \ --query "[name, customRdpProperty]" |
Reset all custom RDP properties
If you want to reset all custom RDP properties, you should use the following command.
1 2 3 4 5 | az desktopvirtualization hostpool update --name $hostPoolName \ --resource-group $resourceGroupName \ --custom-rdp-property "" |
In the following article, I’ll explain how to configure RDP properties for a Host Pool – Device redirection.
Check out this link to learn more about Configuring Device redirections.