Forum Discussion
Kesavan Munuswamy
Jun 05, 2020Copper Contributor
Re assign user to Session host in Personal Pool desktop
Hi All, Good Day!!!, We deployed WVD Spring 2020 setup , we provisioned some set of Personal Pool-Personal Desktop and assigned to respective users into each sesionhost . Now the issue is we need t...
- Jun 06, 2020
Kesavan Munuswamy Hi, unfortunately you cannot re-assign a host to a user. The quickest way to do this is to delete the existing host and just add in another one.
If you don't want to remove and re-deploy you can re-install the wvd broker agent on the VM using the following steps
1) Remove the host from the pool
2) RDP onto the VM and uninstall the WVD Broker Agent
3) Generate a new token from the portal
4) Re-install the agent using the token
5) Assign the host to the user
Hope that helps!
virtualmanc
Jun 06, 2020Iron Contributor
Kesavan Munuswamy Hi, unfortunately you cannot re-assign a host to a user. The quickest way to do this is to delete the existing host and just add in another one.
If you don't want to remove and re-deploy you can re-install the wvd broker agent on the VM using the following steps
1) Remove the host from the pool
2) RDP onto the VM and uninstall the WVD Broker Agent
3) Generate a new token from the portal
4) Re-install the agent using the token
5) Assign the host to the user
Hope that helps!
- PatrickBrechbiehl1966Oct 29, 2021Copper Contributor
Hi virtualmanc
Thanks for your answer, it's exactely what I was looking for.
I just have a question : how do you generate a new token ?
- EirikVNov 02, 2021Copper Contributor
Azure Virtual Desktop --> Host Pools --> Your host pool --> Registration Key --> Generate new key
- EirikVJun 25, 2020Copper Contributor
This worked for me.
1) Remove the host from the pool
2) Generate new token
3) HKLM\Software\Microsoft\RDInfraAgent --> Enter new token in "RegistrationToken"
4) HKLM\Software\Microsoft\RDInfraAgent --> Set "IsRegistered" to "0".5) Reboot the session host
6) Assign the host to the user
It will probably work without reboot if you restart the correct services.- Kesavan MunuswamyJun 28, 2021Copper ContributorHi Eirikv, Good Day!!!, I was found this 2 registry Key value update would be the easy and fasted way to do the changes i was done bunch of instances with this way.
Thanks, by Kesavan K M - rahulsarkarJun 28, 2021Copper Contributor
Yes I have confirmed it works without a Reboot.
This gentleman's code helped me out
https://github.com/marcelin/AzureStartVmOnConnect/blob/20d841e936a8767d49e0da02c06e3b97657fc997/WVD/ReassignPersonalVM/ReassignPersonalVM.ps1$strRoleDefinitionName = "Desktop Virtualization User" $strResourceName = "appgrp-wvd-xxx-yyy-std-01" $strResourceType = 'Microsoft.DesktopVirtualization/applicationGroups' $strResourceGroupName = "rg-prd-xxx-yyy-001" $SessionHostName = "WVDSessionHostName" $SessionHostAdminCreds = Get-Credential Set-AzContext -SubscriptionName Your-Subscription $CommonParams = @{ ResourceGroupName = $strResourceGroupName; HostPoolName = "wvd-prd-xxx-yyy-001" } Write-Host "###... Removing role $strRoleDefinitionName for the user $User..." Remove-AzRoleAssignment -SignInName $User -RoleDefinitionName $strRoleDefinitionName -ResourceName $strResourceName -ResourceGroupName $strResourceGroupName -ResourceType $strResourceType Write-Host "###... Removing WVD Host $SessionHostName for the user $User..." Remove-AzWvdSessionHost -Name $SessionHostName @CommonParams -Force $RegInfo = New-AzWvdRegistrationInfo -ExpirationTime (Get-Date).AddDays(1) @CommonParams Write-Host "###... Generated new registration token ... $RegInfo..." Invoke-Command -ComputerName $SessionHostName -Credential $SessionHostAdminCreds -ScriptBlock { param($RegistrationToken) Write-Host "### Entered host $(hostname), starting adding back to the hostpool." Set-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\RDInfraAgent\ -Name IsRegistered -Value 0 -passthru Set-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\RDInfraAgent\ -Name RegistrationToken -Value $RegistrationToken -Passthru Write-Host "###... Changed registry values ..." #Not sure if this is required Restart-Service RDAgent Write-Host "###... Restarted RDAgent service ..." #This kicked off the registration Start-service RDAgentBootLoader Write-Host "###... Restarted RDAgentBootLoader service ..." } -ArgumentList $RegInfo.token
I have tested it and works like a charm. Whew! Thanks!