Forum Discussion
Re assign user to Session host in Personal Pool desktop
- 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!
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!
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!