Hi, Jorge is back. As I mentioned in my previous post, I will show you the second part of configuring device redirections for your Azure Virtual Desktop environment using PowerShell and Azure CLI. If you missed the first part, here is the link. Ok, let’s go through each setting one by one.
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 Local devices redirection
To set a custom RDP property, you should use the Update-AzWvdHostPool cmdlet.
Camera redirection
- camerastoredirect:s: – Don´t redirect any cameras.
1 2 3 4 5 | Update-AzWvdHostPool -Name $hostPoolName ` -ResourceGroupName $resourceGroupName ` -CustomRdpProperty "camerastoredirect:s:" |
- camerastoredirect:s:* – Redirect all cameras.
1 2 3 4 5 | Update-AzWvdHostPool -Name $hostPoolName ` -ResourceGroupName $resourceGroupName ` -CustomRdpProperty "camerastoredirect:s:*" |
- camerastoredirect:s: – Manually enter a list of cameras. Specific cameras are redirected using a semicolon-delimited list of interfaces KSCATEGORY_VIDEO_CAMERA.
1 2 3 4 5 | Update-AzWvdHostPool -Name $hostPoolName ` -ResourceGroupName $resourceGroupName ` -CustomRdpProperty "camerastoredirect:s:\\?\\USB#VID_04F2&PID_B422&MI_00\;\\?\\USB#VID_04F2&PID_B480&MI_00" |
MTP and PTP device redirection
This setting allows plug-and-play devices, PTP digital cameras, or MTP music players to be redirected. These are the accepted values.
- devicestoredirect:s: – Don’t redirect any device.
1 2 3 4 5 | Update-AzWvdHostPool -Name $hostPoolName ` -ResourceGroupName $resourceGroupName ` -CustomRdpProperty "devicestoredirect:s:" |
- devicestoredirect:s:* – Redirect all plug-and-play devices.
1 2 3 4 5 | Update-AzWvdHostPool -Name $hostPoolName ` -ResourceGroupName $resourceGroupName ` -CustomRdpProperty "devicestoredirect:s:*" |
Drive/storage redirecction
- drivestoredirect:s: – Don’t redirect any drives.
1 2 3 4 5 | Update-AzWvdHostPool -Name $hostPoolName ` -ResourceGroupName $resourceGroupName ` -CustomRdpProperty "drivestoredirect:s:" |
- drivestoredirect:s:* – Redirect all disk drives, including ones that are connected later.
1 2 3 4 5 | Update-AzWvdHostPool -Name $hostPoolName ` -ResourceGroupName $resourceGroupName ` -CustomRdpProperty "drivestoredirect:s:*" |
- drivestoredirect:s:dynamicdrives – Dynamics drives: redirect any drives that are connected later.
1 2 3 4 5 | Update-AzWvdHostPool -Name $hostPoolName ` -ResourceGroupName $resourceGroupName ` -CustomRdpProperty "drivestoredirect:s:dynamicdrives" |
- drivestoredirect:s: – Manually enter drives and labels. Specific drives using a semicolon-delimited list.
1 2 3 4 5 | Update-AzWvdHostPool -Name $hostPoolName ` -ResourceGroupName $resourceGroupName ` -CustomRdpProperty "drivestoredirect:s:C\:\;F\:\" |
Clipboard redirection
This setting determines whether the clipboard on the client computer will be redirected and available in the remote session. These are the accepted values.
- redirectclipboard:i:0 – Clipboard on local computer isn’t available in remote session.
1 2 3 4 5 | Update-AzWvdHostPool -Name $hostPoolName ` -ResourceGroupName $resourceGroupName ` -CustomRdpProperty "redirectclipboard:i:0" |
- redirectclipboard:i:1 – Clipboard on local computer is available in remote session.
1 2 3 4 5 | Update-AzWvdHostPool -Name $hostPoolName ` -ResourceGroupName $resourceGroupName ` -CustomRdpProperty "redirectclipboard:i:1" |
COM ports redirecction
- redirectcomports:i:0 – COM ports on the local computer are not available in the remote session.
1 2 3 4 5 | Update-AzWvdHostPool -Name $hostPoolName ` -ResourceGroupName $resourceGroupName ` -CustomRdpProperty "redirectcomports:i:0" |
- redirectcomports:i:1 – COM ports on the local computer are available in the remote session.
1 2 3 4 5 | Update-AzWvdHostPool -Name $hostPoolName ` -ResourceGroupName $resourceGroupName ` -CustomRdpProperty "redirectcomports:i:1" |
Location service redirecction
This setting determines whether location sharing on the client computer will be redirected and available in the remote session. These are the accepted values.
- redirectlocation:i:0 – Disable location sharing from the local device.
1 2 3 4 5 | Update-AzWvdHostPool -Name $hostPoolName ` -ResourceGroupName $resourceGroupName ` -CustomRdpProperty "redirectlocation:i:0" |
- redirectlocation:i:1 – Enable location sharing from the local device and redirection to apps in the remote session.
1 2 3 4 5 | Update-AzWvdHostPool -Name $hostPoolName ` -ResourceGroupName $resourceGroupName ` -CustomRdpProperty "redirectlocation:i:1" |
Printer redirection
- redirectprinters:i:0 – The printers on the local computer are not available in the remote session.
1 2 3 4 5 | Update-AzWvdHostPool -Name $hostPoolName ` -ResourceGroupName $resourceGroupName ` -CustomRdpProperty "redirectprinters:i:0" |
- redirectprinters:i:1 – The printers on the local computer are available in the remote session.
1 2 3 4 5 | Update-AzWvdHostPool -Name $hostPoolName ` -ResourceGroupName $resourceGroupName ` -CustomRdpProperty "redirectprinters:i:1" |
Smart card redirecction
- redirectsmartcards:i:0 – The smart card device will not be redirected and available in the remote session.
1 2 3 4 5 | Update-AzWvdHostPool -Name $hostPoolName ` -ResourceGroupName $resourceGroupName ` -CustomRdpProperty "redirectsmartcards:i:0" |
- redirectsmartcards:i:1 – The smart card device will be redirected and available in the remote session.
1 2 3 4 5 | Update-AzWvdHostPool -Name $hostPoolName ` -ResourceGroupName $resourceGroupName ` -CustomRdpProperty "redirectsmartcards:i:1" |
USB device redirecction
- usbdevicestoredirect:s: – Don’t redirect any USB devices.
1 2 3 4 5 | Update-AzWvdHostPool -Name $hostPoolName ` -ResourceGroupName $resourceGroupName ` -CustomRdpProperty "usbdevicestoredirect:s:" |
- usbdevicestoredirect:s:* – Redirect all USB devices.
1 2 3 4 5 | Update-AzWvdHostPool -Name $hostPoolName ` -ResourceGroupName $resourceGroupName ` -CustomRdpProperty "usbdevicestoredirect:s:*" |
- usbdevicestoredirect:s: – Manually enter devices by specifying the instance ID. Specific IDs using a semicolon-delimited list.
1 2 3 4 5 | Update-AzWvdHostPool -Name $hostPoolName ` -ResourceGroupName $resourceGroupName ` -CustomRdpProperty "usbdevicestoredirect:s:72631e54-7894-11d0-bc7-00a007b32a\;53d29ef7-377c-4014-864b-eb3a857693599" |
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 "camerastoredirect:s:*;redirectprinters:i:1;usbdevicestoredirect:s:;drivestoredirect:s:C\:\;F\:\" |
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 Local devices redirection
To set a custom RDP property, you should use the following command.
Camera redirection
- camerastoredirect:s: – Don´t redirect any cameras.
1 2 3 4 5 | az desktopvirtualization hostpool update --name $hostPoolName \ --resource-group $resourceGroupName \ --custom-rdp-property "camerastoredirect:s:" |
- camerastoredirect:s:* – Redirect all cameras.
1 2 3 4 5 | az desktopvirtualization hostpool update --name $hostPoolName \ --resource-group $resourceGroupName \ --custom-rdp-property "camerastoredirect:s:*" |
- camerastoredirect:s: – Manually enter a list of cameras. Specific cameras are redirected using a semicolon-delimited list of interfaces KSCATEGORY_VIDEO_CAMERA.
1 2 3 4 5 | az desktopvirtualization hostpool update --name $hostPoolName \ --resource-group $resourceGroupName \ --custom-rdp-property "camerastoredirect:s:\\?\\USB#VID_04F2&PID_B422&MI_00\;\\?\\USB#VID_04F2&PID_B480&MI_00" |
MTP and PTP device redirection
This setting allows plug-and-play devices, PTP digital cameras, or MTP music players to be redirected. These are the accepted values.
- devicestoredirect:s: – Don’t redirect any device.
1 2 3 4 5 | az desktopvirtualization hostpool update --name $hostPoolName \ --resource-group $resourceGroupName \ --custom-rdp-property "devicestoredirect:s:" |
- devicestoredirect:s:* – Redirect all plug-and-play devices.
1 2 3 4 5 | az desktopvirtualization hostpool update --name $hostPoolName \ --resource-group $resourceGroupName \ --custom-rdp-property "devicestoredirect:s:*" |
Drive/storage redirecction
- drivestoredirect:s: – Don’t redirect any drives.
1 2 3 4 5 | az desktopvirtualization hostpool update --name $hostPoolName \ --resource-group $resourceGroupName \ --custom-rdp-property "drivestoredirect:s:" |
- drivestoredirect:s:* – Redirect all disk drives, including ones that are connected later.
1 2 3 4 5 | az desktopvirtualization hostpool update --name $hostPoolName \ --resource-group $resourceGroupName \ --custom-rdp-property "drivestoredirect:s:*" |
- drivestoredirect:s:dynamicdrives – Dynamics drives: redirect any drives that are connected later.
1 2 3 4 5 | az desktopvirtualization hostpool update --name $hostPoolName \ --resource-group $resourceGroupName \ --custom-rdp-property "drivestoredirect:s:dynamicdrives" |
- drivestoredirect:s: – Manually enter drives and labels. Specific drives using a semicolon-delimited list.
1 2 3 4 5 | az desktopvirtualization hostpool update --name $hostPoolName \ --resource-group $resourceGroupName \ --custom-rdp-property "drivestoredirect:s:C\\:\\;F\\:" |
Clipboard redirection
This setting determines whether the clipboard on the client computer will be redirected and available in the remote session. These are the accepted values.
- redirectclipboard:i:0 – Clipboard on local computer isn’t available in remote session.
1 2 3 4 5 | az desktopvirtualization hostpool update --name $hostPoolName \ --resource-group $resourceGroupName \ --custom-rdp-property "redirectclipboard:i:0" |
- redirectclipboard:i:1 – Clipboard on local computer is available in remote session.
1 2 3 4 5 | az desktopvirtualization hostpool update --name $hostPoolName \ --resource-group $resourceGroupName \ --custom-rdp-property "redirectclipboard:i:1" |
COM ports redirecction
- redirectcomports:i:0 – COM ports on the local computer are not available in the remote session.
1 2 3 4 5 | az desktopvirtualization hostpool update --name $hostPoolName \ --resource-group $resourceGroupName \ --custom-rdp-property "redirectcomports:i:0" |
- redirectcomports:i:1 – COM ports on the local computer are available in the remote session.
1 2 3 4 5 | az desktopvirtualization hostpool update --name $hostPoolName \ --resource-group $resourceGroupName \ --custom-rdp-property "redirectcomports:i:1" |
Location service redirecction
This setting determines whether location sharing on the client computer will be redirected and available in the remote session. These are the accepted values.
- redirectlocation:i:0 – Disable location sharing from the local device.
1 2 3 4 5 | az desktopvirtualization hostpool update --name $hostPoolName \ --resource-group $resourceGroupName \ --custom-rdp-property "redirectlocation:i:0" |
- redirectlocation:i:1 – Enable location sharing from the local device and redirection to apps in the remote session.
1 2 3 4 5 | az desktopvirtualization hostpool update --name $hostPoolName \ --resource-group $resourceGroupName \ --custom-rdp-property "redirectlocation:i:1" |
Printer redirection
- redirectprinters:i:0 – The printers on the local computer are not available in the remote session.
1 2 3 4 5 | az desktopvirtualization hostpool update --name $hostPoolName \ --resource-group $resourceGroupName \ --custom-rdp-property "redirectprinters:i:0" |
- redirectprinters:i:1 – The printers on the local computer are available in the remote session.
1 2 3 4 5 | az desktopvirtualization hostpool update --name $hostPoolName \ --resource-group $resourceGroupName \ --custom-rdp-property "redirectprinters:i:1" |
Smart card redirecction
- redirectsmartcards:i:0 – The smart card device will not be redirected and available in the remote session.
1 2 3 4 5 | az desktopvirtualization hostpool update --name $hostPoolName \ --resource-group $resourceGroupName \ --custom-rdp-property "redirectsmartcards:i:0" |
- redirectsmartcards:i:1 – The smart card device will be redirected and available in the remote session.
1 2 3 4 5 | az desktopvirtualization hostpool update --name $hostPoolName \ --resource-group $resourceGroupName \ --custom-rdp-property "redirectsmartcards:i:1" |
USB device redirecction
- usbdevicestoredirect:s: – Don’t redirect any USB devices.
1 2 3 4 5 | az desktopvirtualization hostpool update --name $hostPoolName \ --resource-group $resourceGroupName \ --custom-rdp-property "usbdevicestoredirect:s:" |
- usbdevicestoredirect:s:* – Redirect all USB devices.
1 2 3 4 5 | az desktopvirtualization hostpool update --name $hostPoolName \ --resource-group $resourceGroupName \ --custom-rdp-property "usbdevicestoredirect:s:*" |
- usbdevicestoredirect:s: – Manually enter devices by specifying the instance ID. Specific IDs using a semicolon-delimited list.
1 2 3 4 5 | az desktopvirtualization hostpool update --name $hostPoolName \ --resource-group $resourceGroupName \ --custom-rdp-property "usbdevicestoredirect:s:72631e54-7894-11d0-bc7-00a007b32a\;53d29ef7-377c-4014-864b-eb3a857693599" |
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 "camerastoredirect:s:*;redirectprinters:i:1;usbdevicestoredirect:s:;drivestoredirect:s:C\\:\\;F\\:" |
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 – Display settings.
Check out this link to learn more about Configuring Device redirection.