vRO scriptable task to identify VMtools

One of the blog articles that gets the most hits on my blog is a article about how to get VMtools status from Powershell.  I figured I would share similar methods using vRO.  If you are wondering the Powershell method takes 10 minutes while the vRO method takes 10 seconds.  It’s pretty impressive.

First you create a scriptable task and get all virtual machines (this will be across all vCenters connected to your vRO instance)

//get list of all VM's
 vms = System.getModule("com.vmware.library.vc.vm").getAllVMs();

now the variable vms has array of VC:VirtualMachine containing all vm’s in your environment.

We now want to run through all vm’s one at a time using for each and check for two things:

  • Tools not running
  • Machine is powered on
for each (vm in vms)
{
if (vm.guest.toolsStatus == VcVirtualMachineToolsStatus.toolsNotRunning && vm.runtime.powerState.value === "poweredOn") {
         //do your reporting or action here
         System.log(vm.name + " tools is not running");
}

}

The VcVirtualMachineToolsStatus scripting class exposes a number of methods to check status including the following:

  • VcVirtualMachineToolsStatus.toolsNotInstalled
  • VcVirtualMachineToolsStatus.toolsNotRunning
  • VcVirtualMachineToolsStatus.toolsOk
  • VcVirtualMachineToolsStatus.toolsOld

As seen here:

Capture

These can be used to identify almost any status of tools.   You can then push your results into an array to use in vRO or vRA.  The full script can be found here: tools



	

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.