VMware Cloud Community
Najtsob
Enthusiast
Enthusiast
Jump to solution

How to check if vmware tools are up to date and whether they run or not ?

So how can I do this in powercli ?

Using (get-view -viobject $vm).Config.Tools, I can get some info but not whether they run or not and are they up to date.

I'd like to get sometnih like I see in vSphere client (OK - if tools are up to date and running, ...)

Best regards, Primoz

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Is this what you are looking for ?

Get-VM | select Name,@{N="Tools Status";E={$_.Guest.Extensiondata.ToolsVersionStatus}}

Note that this property returns one of the enum values from VirtualMachineToolsVersionStatus.

In the vSphere client these values are translated to "OK","Not running","Out of date" and "Not installed".

If you want to see that text you can do the following

Get-VM | select Name,
    @{N="Tools Status";E={
        if($_.Guest.Extensiondata.GuestState -eq "notRunning"){
            "Not running"        }
        else{
            $_.Guest.Extensiondata.ToolsVersionStatus.Replace("guestToolsNeedUpgrade","Out of date").Replace("guestToolsNotInstalled","Not installed").Replace("guestToolsCurrent","OK").Replace("guestToolsUnmanaged","Unmanaged")
        }
    }}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

3 Replies
LucD
Leadership
Leadership
Jump to solution

Is this what you are looking for ?

Get-VM | select Name,@{N="Tools Status";E={$_.Guest.Extensiondata.ToolsVersionStatus}}

Note that this property returns one of the enum values from VirtualMachineToolsVersionStatus.

In the vSphere client these values are translated to "OK","Not running","Out of date" and "Not installed".

If you want to see that text you can do the following

Get-VM | select Name,
    @{N="Tools Status";E={
        if($_.Guest.Extensiondata.GuestState -eq "notRunning"){
            "Not running"        }
        else{
            $_.Guest.Extensiondata.ToolsVersionStatus.Replace("guestToolsNeedUpgrade","Out of date").Replace("guestToolsNotInstalled","Not installed").Replace("guestToolsCurrent","OK").Replace("guestToolsUnmanaged","Unmanaged")
        }
    }}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Najtsob
Enthusiast
Enthusiast
Jump to solution

Thank you very much. Works like a charm Smiley Happy

0 Kudos
mazdajai
Contributor
Contributor
Jump to solution

How can add the following to a script so that if answer equal "not running", the script terminates.

Get-VM | select Name,@{N="Tools Status";E={$_.Guest.Extensiondata.ToolsVersionStatus}}

0 Kudos