Skip to content

Commit a4fb42b

Browse files
committed
Updated code.
1 parent e7be556 commit a4fb42b

File tree

1 file changed

+46
-29
lines changed

1 file changed

+46
-29
lines changed

articles/virtual-desktop/configure-host-pool-personal-desktop-assignment-type.md

Lines changed: 46 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Azure Virtual Desktop personal desktop assignment type - Azure
33
description: How to configure automatic or direct assignment for an Azure Virtual Desktop personal desktop host pool.
44
author: Heidilohr
55
ms.topic: how-to
6-
ms.date: 02/24/2023
6+
ms.date: 03/02/2023
77
ms.author: helohr
88
ms.custom: devx-track-azurepowershell
99
manager: femila
@@ -22,6 +22,18 @@ You can configure the assignment type of your personal desktop host pool to adju
2222

2323
This article assumes you've already downloaded and installed the Azure Virtual Desktop PowerShell module. If you haven't, follow the instructions in [Set up the PowerShell module](powershell-module.md).
2424

25+
### Define variables
26+
27+
The PowerShell commands listed in this article require defining the following variables:
28+
29+
```powershell
30+
#Define variables
31+
$subscriptionId = '00000000-0000-0000-0000-000000000000'
32+
$resourceGroupName = 'MyResourceGroupName'
33+
$hostPoolName = 'MyHostPoolName'
34+
$sessionHostName = 'SessionHostName'
35+
```
36+
2537
## Personal host pools overview
2638

2739
A personal host pool is a type of host pool that has personal desktops. Personal desktops have one-to-one mapping, which means a single user can only be assigned to a single personal desktop. Every time the user signs in, their user session is directed to their assigned personal desktop session host. This host pool type is ideal for customers with resource-intensive workloads because user experience and session performance will improve if there's only one session on the session host. Another benefit of this host pool type is that user activities, files, and settings persist on the virtual machine operating system (VM OS) disk after the user signs out.
@@ -83,7 +95,7 @@ To directly assign a user to a session host in the Azure portal:
8395
11. Select the user you want to assign the session host to from the list of available users.
8496
12. When you're done, select **Select**.
8597

86-
## How to unassign a personal desktop using the Azure portal
98+
## Unassign a personal desktop using the Azure portal
8799

88100
To unassign a personal desktop in the Azure portal:
89101

@@ -103,22 +115,23 @@ To unassign a personal desktop in the Azure portal:
103115
104116
8. Select **Unassign** when prompted with the warning.
105117

106-
## How to unassign a personal desktop using PowerShell
118+
## Unassign a personal desktop using PowerShell
107119

108120
To unassign a personal desktop in PowerShell, run the following command:
109121

110122
```powershell
111-
$patchParams = @{
112-
  Path = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/sessionHosts/{sessionHostName}?api-version=2022-02-10-preview&force=true'
113-
  Payload = '{ "properties": {
114-
     "assignedUser": ""
115-
     } }'
116-
  Method = 'PATCH'
123+
$unassignDesktopParams = @{
124+
Path = "/subscriptions/$subscriptionId/resourceGroups/$resourceGroupName/providers/Microsoft.DesktopVirtualization/hostPools/$hostPoolName/sessionHosts/$($sessionHostName)?api-version=2022-02-10-preview&force=true"
125+
Payload = @{
126+
properties = @{
127+
assignedUser = ''
128+
}} | ConvertTo-Json
129+
Method = 'PATCH'
117130
}
118-
Invoke-AzRestMethod @patchParams
131+
Invoke-AzRestMethod @unassignDesktopParams
119132
```
120133

121-
## How to reassign a personal desktop using the Azure portal
134+
## Reassign a personal desktop using the Azure portal
122135

123136
To reassign a personal desktop in the Azure portal:
124137
1. Sign in to the [Azure portal](https://portal.azure.com).
@@ -138,26 +151,27 @@ To reassign a personal desktop in the Azure portal:
138151
8. Select the user you want to assign the session host to from the list of available users.
139152
9. When you're done, select **Select**.
140153

141-
## How to reassign a personal desktop using PowerShell
154+
## Reassign a personal desktop using PowerShell
142155

143156
To reassign a personal desktop, run this command:
144157

145158
```powershell
146-
$patchParams = @{
147-
  Path = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/sessionHosts/{sessionHostName}?api-version=2022-02-10-preview&force=true'
148-
  Payload = '{ "properties": {
149-
     "assignedUser": "{UPN of new user}"
150-
     } }'
151-
  Method = 'PATCH'
159+
$reassignDesktopParams = @{
160+
Path = "/subscriptions/$subscriptionId/resourceGroups/$resourceGroupName/providers/Microsoft.DesktopVirtualization/hostPools/$hostPoolName/sessionHosts/$($sessionHostName)?api-version=2022-02-10-preview&force=true"
161+
Payload = @{
162+
properties = @{
163+
assigneduser = 'UPN of new user'
164+
}} | ConvertTo-Json
165+
Method = 'PATCH'
152166
}
153-
Invoke-AzRestMethod @patchParams
167+
Invoke-AzRestMethod @reassignDesktopParams
154168
```
155169

156170
## Give session hosts within a personal host pools a friendly name
157171

158172
You can give personal desktops you create *friendly names* to help users distinguish them in their feeds.
159173

160-
To give a host pool a friendly name, run the following command:
174+
To give a host pool a friendly name, run the following command in PowerShell:
161175

162176
```powershell
163177
$body = '{ "properties": {
@@ -185,14 +199,17 @@ Invoke-AzRestMethod @parameters
185199
To assign the session host friendly name, run this command in PowerShell:
186200

187201
```powershell
188-
$patchParams = @{
189-
  Path = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/sessionHosts/{sessionHostName}?api-version=2022-02-10-preview'
190-
  Payload = '{ "properties": {
191-
     "friendlyName": "Friendly Name"
192-
     } }'
193-
  Method = 'PATCH'
202+
#Set the friendly name (Change <myFriendlyName>)
203+
$setNameParams = @{
204+
Path = "/subscriptions/$subscriptionId/resourceGroups/$resourceGroupName/providers/Microsoft.DesktopVirtualization/hostPools/$hostPoolName/sessionHosts/$($sessionHostName)?api-version=2022-02-10-preview"
205+
Payload = @{
206+
properties = @{
207+
friendlyName = 'myFriendlyName'
208+
}
209+
} | ConvertTo-Json
210+
Method = 'PATCH'
194211
}
195-
Invoke-AzRestMethod @patchParams
212+
Invoke-AzRestMethod @setNameParams
196213
```
197214

198215
### Get the session host friendly name
@@ -201,8 +218,8 @@ To get the session host friendly name, run this command in PowerShell
201218

202219
```powershell
203220
$getParams = @{
204-
  Path = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/sessionHosts/{sessionHostName}?api-version=2022-02-10-preview'
205-
  Method = 'GET'
221+
Path = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/sessionHosts/{sessionHostName}?api-version=2022-02-10-preview'
222+
Method = 'GET'
206223
}
207224
Invoke-AzRestMethod @getParams
208225
```

0 commit comments

Comments
 (0)