Skip to content

Commit 78024ea

Browse files
committed
Adding initial commands.
1 parent 6de040c commit 78024ea

File tree

1 file changed

+60
-3
lines changed

1 file changed

+60
-3
lines changed

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

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,10 @@ To directly assign a user to a session host in the Azure portal:
8383
11. Select the user you want to assign the session host to from the list of available users.
8484
12. When you're done, select **Select**.
8585

86-
87-
## How to unassign a personal desktop
86+
## How to unassign a personal desktop using the Azure portal
8887

8988
To unassign a personal desktop in the Azure portal:
89+
9090
1. Sign in to the [Azure portal](https://portal.azure.com).
9191
2. Enter **Azure Virtual Desktop** into the search bar.
9292
3. Under **Services**, select **Azure Virtual Desktop**.
@@ -103,7 +103,22 @@ To unassign a personal desktop in the Azure portal:
103103
104104
8. Select **Unassign** when prompted with the warning.
105105

106-
## How to reassign a personal desktop
106+
## How to unassign a personal desktop using PowerShell
107+
108+
To unassign a personal desktop in PowerShell, run the following command:
109+
110+
```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'
117+
}
118+
Invoke-AzRestMethod @patchParams
119+
```
120+
121+
## How to reassign a personal desktop using the Azure portal
107122

108123
To reassign a personal desktop in the Azure portal:
109124
1. Sign in to the [Azure portal](https://portal.azure.com).
@@ -123,6 +138,21 @@ To reassign a personal desktop in the Azure portal:
123138
8. Select the user you want to assign the session host to from the list of available users.
124139
9. When you're done, select **Select**.
125140

141+
## How to reassign a personal desktop using PowerShell
142+
143+
To reassign a personal desktop, run this command:
144+
145+
```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'
152+
}
153+
Invoke-AzRestMethod @patchParams
154+
```
155+
126156
## Give session hosts within a personal host pools a friendly name
127157

128158
You can give personal desktops you create *friendly names* to help users distinguish them in their feeds.
@@ -150,6 +180,33 @@ Invoke-AzRestMethod @parameters
150180
>[!NOTE]
151181
>You can also set the friendly name by using a [REST API](/rest/api/desktopvirtualization/session-hosts/update?tabs=HTTP).
152182
183+
## Assign the session host friendly name
184+
185+
To assign the session host friendly name, run this command in PowerShell:
186+
187+
```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'
194+
}
195+
Invoke-AzRestMethod @patchParams
196+
```
197+
198+
### Get the session host friendly name
199+
200+
To get the session host friendly name, run this command in PowerShell
201+
202+
```powershell
203+
$getParams = @{
204+
  Path = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/sessionHosts/{sessionHostName}?api-version=2022-02-10-preview'
205+
  Method = 'GET'
206+
}
207+
Invoke-AzRestMethod @getParams
208+
```
209+
153210
## Next steps
154211

155212
Now that you've configured the personal desktop assignment type, you can sign in to an Azure Virtual Desktop client to test it as part of a user session. These articles will show you how to connect to a session using the client of your choice:

0 commit comments

Comments
 (0)