Procedure (we start with steps 1 to 3 in order to reset the account password and Remote Desktop Connection configuration to allow you to log into the VM - otherwise you'll get an error that this has is currently being prevented by an administrator policy, or similar):
- Go to the virtual machine's properties in the Azure portal
- On the left of the VM properties, scroll down 'Reset Password' under 'Help'
- Enter the new password for the svc_local_admin account (you can use a temporary one of your own, but better to use the standard password for the local account name stored in a key vault) and then click 'Update'
- At this point you can now RDP to the VM and login with the local admin account svc_local_admin account and the password just updated
- When logged in, go to Add/Remove Programs and uninstall both the 'Remote Desktop Agent Bootloader' and 'Remote Desktop Services Infrastructure Agent'
- Once done, open File Explorer and navigate to 'C:\DeployAgent' and ensure you have two subfolders there called 'RDAgentBootLoaderInstall' and 'RDInfraAgentInstall', both with MSI installers (if you don't have this path ot the installers are unavailable then these can be downloaded from here, for the agent, and here, for the boot loader.)
- We start with the Agent installation. You can either double-click the MSI installer in the 'C:\DeployAgent\RDInfraAgentInstall' folder (or where you've downloaded it to or, if you get ann error preventing the install, open a PowerShell Administrator shell session by opening PowerShell as Administrator, navigating to the MSI installer directory from PowerShell and running 'Start-Process -FilePath <path-to-the-agent-msi-installer>'
- When the enter token dialog appears (see below) then copy and paste the token from either a key vault relevant to the host pool you're manually adding the VM to
or go to Azure Virtual Desktop in Azure, click Host Pools and then click to select the host pool you want to add the VM to and then click 'Registration Key' to display the registration token for the pool (see below) and copy and paste this into the token dialog text box to proceed
- When done, we the go the agent boot loader installation. You can either double-click the MSI installer in the 'C:\DeployAgent\RDAgentBootLoaderInstall' folder (or where you've downloaded it to or, if you get ann error preventing the install, open a PowerShell Administrator shell session by opening PowerShell as Administrator, navigating to the boot loader MSI installer directory from PowerShell and running 'Start-Process -FilePath <path-to-the-agent-boot-loader-msi-installer>'
- When do, return to 'Add/Remove Programs' to check that the Agent and BootLoader have been successfully installed.
After these steps, you can navigate back to the Azure portal > Azure Virtual Desktop > Host Pools and then click to select the target host pool and then click on 'Total Machines' or Session Hosts on the left to verify that the VM has been added back to the host pool. You may need to wait up to a minute to see it and wait a few seconds before its status changes from Unavailable to Available. If it doesn't appear, then it's likely that the host pool Registration Token use was incorrect.