Concepts
Microsoft Azure Virtual Desktop allows you to assign and unassign personal desktops for users. This can be done through PowerShell cmdlets or the Azure portal. In this article, we will guide you through the process of configuring and operating personal desktops for your users.
Assigning Personal Desktops using PowerShell
- Start by launching PowerShell with administrative privileges.
- Install the Azure PowerShell module if you haven’t already done so, by running the following command:
Install-Module -Name Az.OperationalInsights -AllowClobber -Force
- Connect to your Azure account by running the following command:
Connect-AzAccount
- Create a virtual machine to serve as the personal desktop template. Specify the necessary configurations such as the virtual machine size, image, and other properties. For example:
$vmName = "MyDesktopVM"
$adminUser = "adminuser"
$adminPassword = ConvertTo-SecureString -String "AdminPassword123!" -AsPlainText -Force
$location = "East US"
$vmConfig = New-AzVMConfig -VMName $vmName -VMSize "Standard_D2s_v3"
$vmConfig = Set-AzVMOperatingSystem -VM $vmConfig -Windows -ComputerName $vmName -Credential (New-Object System.Management.Automation.PSCredential $adminUser, $adminPassword) -ProvisionVMAgent -EnableAutoUpdate
$vmConfig = Set-AzVMSourceImage -VM $vmConfig -PublisherName "MicrosoftWindowsDesktop" -Offer "Windows-10" -Skus "19h2-pro" -Version "latest"
$vmConfig = Set-AzVMOSDisk -VM $vmConfig -Name "$vmName-C-OSDisk" -VhdUri $osDiskUri -CreateOption FromImage -SourceImageUri $sourceImageUri -Windows
$vm = New-AzVM -ResourceGroupName "MyResourceGroup" -Location $location -VM $vmConfig
- Generalize and capture the virtual machine image to be used for personal desktops:
Set-AzVM -ResourceGroupName "MyResourceGroup" -Name $vmName -Generalized
Set-AzVm -ResourceGroupName "MyResourceGroup" -Name $vmName -Capture -DestinationContainerName "mycontainer" -VHDNamePrefix "image" -Overwrite
- Create a host pool for personal desktops by running the following command:
New-AzDesktopHostPool -TenantId "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -ResourceGroupName "MyResourceGroup" -HostPoolName "MyHostPool" -Location "East US" -FriendlyName "MyHostPool" -MaxSessionLimit 10 -LoadBalancerType BreadthFirst
- Assign a user to a personal desktop within the host pool:
Add-AzUserAssignedDesktop -TenantId "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -ResourceGroupName "MyResourceGroup" -HostPoolName "MyHostPool" -UserPrincipalName "user@contoso.com" -RegistrationInfo (New-AzDesktop RegistrationInfo -PersonalVirtualDesktopAssignment -VirtualMachineId "/subscriptions/
Unassigning Personal Desktops using Azure portal
- Open the Azure portal (https://portal.azure.com) and navigate to your Azure Virtual Desktop resource.
- In the left menu, click on “Host pools” and select the host pool containing the personal desktop you want to unassign.
- Under the “User assignments” tab, select the user assignment you wish to remove.
- Click on the “Remove” button and confirm the action when prompted.
By following these steps, you can easily assign and unassign personal desktops for users in Microsoft Azure Virtual Desktop. You can automate these processes using scripts or integrate them with your existing infrastructure management tools to streamline user management in your environment.
Answer the Questions in Comment Section
Which PowerShell cmdlet is used to assign a personal desktop to a user in Azure Virtual Desktop?
a) Set-AzVirtualDesktop
b) Assign-AzVirtualDesktop
c) Add-AzVirtualDesktopUser
d) New-AzVirtualDesktopUser
Correct answer: c) Add-AzVirtualDesktopUser
True or False: When assigning a personal desktop to a user, the user must already have an Azure Active Directory (AAD) account.
Correct answer: True
How can you unassign a personal desktop from a user in Azure Virtual Desktop?
a) Remove-AzVirtualDesktop
b) Revoke-AzVirtualDesktopUser
c) Disable-AzVirtualDesktopUser
d) Remove-AzVirtualDesktopUser
Correct answer: d) Remove-AzVirtualDesktopUser
True or False: When unassigning a personal desktop from a user, the user’s data on the desktop is permanently deleted.
Correct answer: False
Which user assignment type is available in Azure Virtual Desktop?
a) Random Assignment
b) Pooled Assignment
c) Exclusive Assignment
d) Shared Assignment
Correct answer: b) Pooled Assignment
True or False: Personal desktops in Azure Virtual Desktop can only be assigned to individual users and not to groups.
Correct answer: False
What is the maximum number of personal desktops that can be assigned to a single user in Azure Virtual Desktop?
a) 1
b) 5
c) 10
d) Unlimited
Correct answer: d) Unlimited
True or False: Personal desktop assignments can be managed using the Azure portal, PowerShell, or the Azure Virtual Desktop REST API.
Correct answer: True
Which PowerShell cmdlet is used to retrieve the list of assigned personal desktops for a user in Azure Virtual Desktop?
a) Get-AzVirtualDesktop
b) Fetch-AzVirtualDesktop
c) Get-AzVirtualDesktopUser
d) Retrieve-AzVirtualDesktopUser
Correct answer: c) Get-AzVirtualDesktopUser
True or False: By default, users can unassign their own personal desktops in Azure Virtual Desktop.
Correct answer: False
Does anyone know the best practices for assigning personal desktops to users in Azure Virtual Desktop?
I’m having trouble unassigning a desktop from a user. Can anyone help?
Great blog post, very informative!
What are some common issues faced while assigning desktops in AVD?
Can multiple users be assigned the same desktop in AVD?
Great post on AZ-140! I just completed the section on assigning personal desktops. Does anyone have tips for handling multiple assignments efficiently?
Using PowerShell scripts can significantly speed up the process. Have you tried that?
Azure CLI has some useful commands too. It might be worth exploring!
I appreciate the detailed guide, really helped me understand the unassignment process.
When you unassign a desktop, what happens to the user’s data? Does anyone know if it’s backed up automatically?
The user data usually resides in a profile container like FSLogix. So, unless you delete the container, the data should remain intact.
Make sure to configure proper backup for FSLogix containers to avoid losing data.