VMware, Inc. 2
Extending Virtual Machine Deletion with Scripts
Thenextexampleshowshowyoucouldextractthenameofthevirtualmachine,andusethisvaluetodelete
thecorrespondingentryfromActiveDirectory.
Dim shell
set shell = WScript.CreateObject( "WScript.Shell" )
set vmName = shell.ExpandEnvironmentStrings("%VDM_DeleteVm_VmName%")
set machineObj = GetObject("LDAP://CN=" & vmName & ",CN=Desktops,DC=MYDOMAIN,DC=COM")
machineObj.DeleteObject(0)
ThisexampleassumesthatthescriptrunswiththeadministrativerightstoupdateentriesinActiveDirectory.
YoumustmodifythescripttocorrespondtotheconfigurationofyourlocalsystemsinActiveDirectory.
Add a Windows Registry Entry for a Deletion Script
Tomakeadeletionscriptavailableforexecution,youmustaddittotheWindowsregistry.Youmustcreatean
entryoneachViewConnectionServerinstancewhereyouwantViewManagertorunthedeletionscriptwhen
youdeleteavirtualmachine.
To add an entry for a deletion script to the registry on a View Connection Server instance
1StarttheWindowsRegistryEditorbyenteringregeditatthecommandprompt.
2Intheregistry,navigatetoHKLM\SOFTWARE\VMware, Inc.\VMware VDM\ScriptEvents.
3Inthenavigationarea,right‐clickScriptEvents,selectNew>Key,andcreateakeynamedDeleteVm.
4Inthenavigationarea,right‐clickDeleteVm,selectNew>StringVa l ue,andcreateastringvaluethat
identifiesthedeletionscripttoberun.
Torunmorethanonedeletionscript,createastringvalueentryforeachscriptundertheDeleteVmkey.
Youcannotspecifytheorderinwhichthesescriptsrun.Ifthescriptsmustruninaspecifiedorder,invoke
themfromasinglecontrolscript.
5Inthetopicarea,right‐clickontheentryforthenewstringvalue,andselectModify.
6InValue data,enterthecommandlinethatinvokesthedeletionscript,andclickOK.
Specifythefullpathofthedeletionscriptandanyfilesthatitrequires.
7IfyouwanttheVMwareViewScriptHostservicetotimeoutthedeletionscript,rightclickontheDefault
key,selectModify,enterthetimeoutvalueinmilliseconds,andclickOK.
8ExittheRegistryEditor,andrestartthesystem.
Configure the VMware View Script Host Service
YoumustconfiguretheVMwareViewScriptHostserviceoneachViewConnectionServerinstancewhereyou
wantViewManagertorunthedeletionscript.Bydefault,theVMwareViewScriptHostserviceisdisabled.
To configure the VMware View Script Host service
1StarttheWindowsServicestoolbyenteringservices.mscatthecommandprompt.
2Inthedetailspane,right‐clickontheVMwareViewScriptHostserviceentry,andselectProperties.
3OntheGeneraltab,inStartuptype,selectAutomatic.
4Ifyoudonotwantthelocalsystemaccounttorunthedeletionscript,selectThisaccount,andenterthe
detailsoftheaccounttorunthedeletionscript.
5ClickOK,andexittheServicestool.
CAUTIONRunningadeletionscriptunderthelocalsystemaccountcouldcompromisethesecurityoftheView
ConnectionServerhost.Ifyouconfigureanaccountotherthanthelocalsystemaccounttorunadeletionscript,
verifythattheaccounthasreadpermissionontheregistrykeyforthescript.Youshouldalsolimitthe
administrativerightsofadeletionscripttothoserightsthatallowittoperformitsfunction.