Friday, July 20, 2018

Remove VMware Horizon View VMs and Desktop Pools stuck in Deleting stage.

I have had several times where the Horizon Pool will not delete all the way, the VMs are stuck in a deleting phase (note: the VMs are gone from vCenter, just not from the inventory). That makes the Desktop Pool get stuck and Chaos ensues.

Most Recently I got stuck for several days before I found this article. I have made some additions, changes and comments to the process, but credit to Jacob Gardiner for the screen shots and SQL deep dive.

From Jacob's Blog - My Comments and suggestions below are in BLUE and RED

I have recently experienced an issue with VMware View Desktop Pools, I tried to remove a Desktop Pool but it did not successfully complete and it had been stuck in the ‘Deleting’ stage. You will need to complete the following steps to successfully remove these Desktop Pools. (You may not need to do all of this, if your VMs are gone and it's just the inventory in the admin tool, the ADSI will suffice)
Firstly you will need to remove the machines from the ADAM Database on the Horizon View Connection Server. We will need to use ADSI Edit to complete the removal of these objects.

NOTE: This assumes that you are RDPed into the Connection Manager Server. I am a BIG proponent of Admin VMs with all of your remote tools on them and NEVER RDPing int a server unless it is necessary. I HIGHLY Recommend running ADSI Edit from your Admin VM and using the following:
Select or Type a Distinguished Name or Naming Context – dc=vdi,dc=vmware,dc=int
Select or Type a Domain or Server 
  Actual Server – NET-00-HCM-01:389
You will need to navigate to ADSI Edit, You can complete this by typing adsiedit.msc in to a Run box. You will now need to select Action, then Connect To. You will need to put in the following information in the connection settings.
Select or Type a Distinguished Name or Naming Context – dc=vdi,dc=vmware,dc=int
Select or Type a Domain or Server – localhost:389
VMware View ADAM Connection Settings - Removing VMware Horizon View Desktop Pools Stuck In 'Deleting' stage
Once connected you will see the following in the left hand column.
ADSI Edit Default Naming Context - Removing VMware Horizon View Desktop Pools Stuck In 'Deleting' stage
We now need to create a query to search for the machines that we are trying to remove from the database. We will now need to create a query to find the machines that are in the ADAM Database. You can complete this by right clicking ‘Default Naming Context’ and selecting New –> Query. You need to fill in the New Query box with the following information –
Name – This can be a name of your choice.
Root of Search – This needs to be the ‘Servers’ folder.
Query String – (&(objectClass=pae-VM)(pae-displayname=VirtualMachineName))
The VirtualMachineName above should ACTUALLY BE your VM Name, or a wild card like NET-VMX-1* that gets just the VMs you need to delete. Most people don't need to delete all of them.
ADAM VM Query - Removing VMware Horizon View Desktop Pools Stuck In 'Deleting' stage
I would advise using the * Icon as a Wildcard for the VirtualMachineName if you are trying to remove multiple entries at once as this will show them all.
ADAM VM Query Wildcard - Removing VMware Horizon View Desktop Pools Stuck In 'Deleting' stage
You will now be presented with the following results in the VM Query section.
ADAM VM Query Results - Removing VMware Horizon View Desktop Pools Stuck In 'Deleting' stage
You will now need to locate the relevant VM’s that you want to remove. The specific fields you should be looking for is the Description and the ipHostNumber field. These fields are the most useful for identifying the virtual machines required. Scroll down in the list and actually find the PAE-DisplayName field. That is the actual name of the VM and is MUCH better for finding your errant VM.
Identify VM - Removing VMware Horizon View Desktop Pools Stuck In 'Deleting' stage
You can now right click the entry and select ‘Delete’ as required.

Normally, I can stop here. Go back and look at the admin console and refresh. The Pool should be gone. If not, then proceed from here.
You will now need to login to the SQL Management Studio to the View Composer Database. In my deployment the View Composer is on the VMware vCenter Server. Login with the relevant credentials you used when you installed VMware View.
Login to Database - Removing VMware Horizon View Desktop Pools Stuck In 'Deleting' stage
You will now need to navigate to the VMware View Composer Database –> Tables –> dbo.SVI_VM_NAME
You will need to right click this and select ‘Edit Top 200 Rows’
SQL dbo.SVI VM NAME - Removing VMware Horizon View Desktop Pools Stuck In 'Deleting' stage
Right click and select ‘Delete’ to the selected VM’s that you want to remove from the database. After this the Desktop Pool was removed in Horizon View.
You should now remove the Computer Account from AD.
You can then remove the VM/VM’s from vCenter by right clicking the VM and selecting Delete from Disk.
To find more information on this process you can follow these KB’s.

No comments:

Post a Comment