To deploy an Azure Virtual Desktop environment using PowerShell, you need to perform the following steps:
- Install the required PowerShell modules:
- Install-Module -Name Az
- Install-Module -Name Az.DesktopVirtualization
- Connect to your Azure account:
- Connect-AzAccount
- Create a resource group:
- $resourceGroupName = “YourResourceGroupName”
- $location = “YourLocation”
- New-AzResourceGroup -Name $resourceGroupName -Location $location
- Create a virtual network:
- $vnetName = “YourVNetName”
- $subnetName = “YourSubnetName”
- $vnet = New-AzVirtualNetwork -ResourceGroupName $resourceGroupName -Location $location -Name $vnetName -AddressPrefix “10.0.0.0/16”
- $subnet = Add-AzVirtualNetworkSubnetConfig -Name $subnetName -AddressPrefix “10.0.0.0/24” -VirtualNetwork $vnet
- $vnet | Set-AzVirtualNetwork
- Create a virtual desktop host pool:
- $hostPoolName = “YourHostPoolName”
- $vmNamePrefix = “YourVMNamePrefix”
- $vmSize = “Standard_DS2_v2”
- $imageOffer = “Windows-10”
- $imagePublisher = “MicrosoftWindowsDesktop”
- $imageSku = “20h2-evd-o365pp”
- $registrationInfo = New-AzDesktopVirtualizationRegistrationInfo -FileUri “https://rdweb.wvd.microsoft.com/api/arm/feeddiscovery“
- $hostPool = New-AzDesktopVirtualizationHostPool -ResourceGroupName $resourceGroupName -Location $location -Name $hostPoolName -FriendlyName $hostPoolName -VmTemplateImageOffer $imageOffer -VmTemplateImagePublisher $imagePublisher -VmTemplateImageSku $imageSku -VmTemplateNamePrefix $vmNamePrefix -VmTemplateVMSize $vmSize -RegistrationInfo $registrationInfo
- Create a workspace:
- $workspaceName = “YourWorkspaceName”
- $workspace = New-AzDesktopVirtualizationWorkspace -ResourceGroupName $resourceGroupName -Location $location -Name $workspaceName -FriendlyName $workspaceName
- Assign users to the host pool:
- $userPrincipalNames = @(“user1@example.com“, “user2@example.com“)
- Add-AzDesktopVirtualizationUser -ResourceGroupName $resourceGroupName -WorkspaceName $workspaceName -HostPoolName $hostPoolName -UserPrincipalName $userPrincipalNames
- Grant the necessary permissions:
- Grant-AzDesktopVirtualizationAppGroupPermission -ResourceGroupName $resourceGroupName -WorkspaceName $workspaceName -HostPoolName $hostPoolName -AppGroupName “Desktop Application Group” -Role “Desktop Application Group User”
That’s it! You have now deployed an Azure Virtual Desktop environment using PowerShell. Please note that some parameter values, such as resource group name, location, virtual network details, and user principal names, should be replaced with your specific values.
Got a project that needs expert IT support?
From Linux and Microsoft Server to VMware, networking, and more, our team at CR Tech is here to help.
Get personalized support today and ensure your systems are running at peak performance or make sure that your project turns out to be a successful one!
CONTACT US NOW