Code: Select all
'On Error Resume Next
'Author: Troy Hockman
'Desc: This script will delete vms stuck in view env. It deletes from the view adam.
sComputer = InputBox("Please enter the exact Desktop name:")
If sComputer = "" Then Wscript.Quit
Set objOU = GetObject("LDAP://localhost:389/ou=Servers,dc=vdi,dc=vmware,dc=int")
objOU.Filter = Array("pae-VM")
For Each objUser in objOU
paedisName = objUser.[pae-DisplayName]
if paedisName = sComputer then
sIsFound = "yes"
intAnswer = Msgbox("The VM " & sComputer & " will be deleted!",vbYesNo, "Delete VM?")
If intAnswer = vbYes Then
Set OU = GetObject(objUser.Parent)
ou.Delete "pae-VM", "CN=" & objUser.cn
Msgbox "You answered yes, so it should be gone."
Else
Msgbox "You answered no, so it is still there."
End If
wscript.quit
End If
Next
if sIsFound <> "yes" then
MsgBox "Sorry could not find " & sComputer
End If
Use at own risk and backup db first.
Delete the VM from the datastore, or from within vCenter, “Delete from Disk”
Go to the Active Directory OU where your pool workstations exist, and delete the computer object from there
Open up the Composer DB database I use Squirrel-SQL and remove records
SVI_VM_NAME where NAME is the deployed VM name
SVI_VM_COMPUTER_NAME where NAME is the deployed VM name
SVI_SC_BASE_DISK_KEYS where PARENT_ID is the ID from SVI_SIM_CLONE
SVI_TASK_STATE where SIM_CLONE_ID is the ID from SVI_SIM_CLONE
SVI_SC_PDISK_INFO where PARENT_ID is the ID from SVI_SIM_CLONE
SVI_SIM_CLONE where VM_NAME is the deployed VM name.
I may get some time and add the steps to the vbs script but needed to get this done.
Here is the original post where I found the Composer DB info, Thanks to them
http://blog.foreignkid.net/2010/08/fixi ... ware-view/