Remove-RdsSessionhost : User is not authorized to query the management service.

New Contributor

Hi,

 

I was half successful in deploying wvd so I want to delete my hostpool and start the deployment again. But I can't delete my hostpool cause I still have a sessionhost in it (the vm is not there anymore). When I try the powershell command Remove-RdsSessionHost with the force parameter I get the error from the subject. When I use the management website i get a general error message that I can't delete the host.

 

I used a Service Principal Name to deploy. I also created a new Service Principal, logged into the wvd environment but that gave the same error message. All accounts I tried it with are RDS Owner and RDS Contributor.

 

Any ideas what else to do?

1 Reply
I have made the Powershell below, to remove the objects, you've already created in a Sessionhost : # Procedure to delete a HostPool and his content $IMHostPoolName = "HERE YOUR HOSTPOOL" $IMTenantName = "HERE YOUR TENANTNAME" # $IMdelhp=Get-RdsHostPool $IMTenantName -HostPoolName $IMHostPoolName $IMdelShTt = Get-RdsSessionHost $ImTenantName $IMHostPoolName $i=0 ForEach ($IMdelSh in $IMdelShTt) { $i=$i+1 Write-Host " SessionHost " $i " : " $IMdelSh.SessionHostName Remove-RdsSessionHost $IMTenantName $IMHostPoolName -Name $IMdelSh.SessionHostName } $IMdelAgTt = Get-RdsAppGroup $IMTenantName $IMHostPoolName $j=0 ForEach ($IMdelAg in $IMdelAgTt) { $j=$j+1 $IMdelUsTt = Get-RdsAppGroupUser $IMTenantName $IMHostPoolName -AppGroupName $IMdelAg.AppGroupName ForEach ($IMdelUs in $IMdelUsTt) { Remove-RdsAppGroupUser $IMTenantName $IMHostPoolName -AppGroupName $IMdelAg.AppGroupName -UserPrincipalName $IMdelUs.UserPrincipalName } $IMdelRaTt = Get-RdsRemoteApp $IMTenantName $IMHostPoolName $IMdelAg.AppGroupName $k=0 ForEach ($IMdelRa in $IMdelRaTt) { $k=$k+1 Remove-RdsRemoteApp $IMTenantName $IMHostPoolName -AppGroupName $IMdelAg.AppGroupName -Name $IMdelRa.FriendlyName } Remove-RdsAppGroup $IMTenantName $IMHostPoolName -Name $IMdelAg.AppGroupName } Remove-RdsHostPool $IMTenantName -HostPoolName $IMHostPoolName