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!
EirikV
Jun 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.
rahulsarkar
Jun 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!