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
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
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
Thank you very much. Works like a charm
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}}