To set up a logon script for an Azure virtual desktop that maps a file share, you will need to follow these steps:
- Create a new file share in Azure Files or in a storage account.
- Create a logon script using the
net usecommand to map the file share to a drive letter on the virtual desktop.
- Upload the logon script to a location that is accessible to the virtual desktop.
- Assign the logon script to the virtual desktop.
Here is an example logon script that maps the file share
\\myfileshare.file.core.windows.net\myshare to the drive letter
net use Z: \\myfileshare.file.core.windows.net\myshare /persistent:yes
To assign the logon script to the virtual desktop, you can use the Azure portal or the Azure PowerShell module. Here is an example of how to do it using the Azure PowerShell module:
- Install the Azure PowerShell module on your local machine.
- Connect to your Azure subscription using the
- Run the following command to set the logon script for the virtual desktop:
Set-AzWvdDesktop -ResourceGroupName 'myResourceGroup' -WorkspaceName 'myWorkspace' -HostPoolName 'myHostPool' -DesktopName 'myDesktop' -LogonScript '\\path\to\logon\script.cmd'
myDesktop with the actual names of your resource group, workspace, host pool, and virtual desktop. Replace
\\path\to\logon\script.cmd with the actual path to the logon script that you uploaded.
When the virtual desktop is restarted, the logon script will be run and the file share will be mapped to the specified drive letter.