Finding vms with vmware tools that need to be upgraded. vmware tools status and version

by Grzegorz Kulikowski

Right, this is not some rocket science here but still i thought some people may be looking for that.
[sourcecode language=”powershell”]
get-cluster your_cluster |Get-VM|?{$_.Extensiondata.Summary.Guest.ToolsVersionStatus -like ‘guestToolsNeedUpgrade’} | select name,@{N=’tools vers’;E={$_.ExtensionData.Config.Tools.ToolsVersion}},@{N=’Tools Status’;E={$_.Extensiondata.Summary.Guest.ToolsVersionStatus}}

So i wanted to take cluster ‘your_cluster’ and get all vms in this cluster that have tools status of ‘guestToolsNeedUpgrade’. Well basically that’s pretty much it but i noticed that on large inventory it takes quite time to receive this list. So what might be interesting for people who have bigger vInfrastructure 😉
This query takes
Seconds : 41
So i spend few more minutes to get the same list but using get-view. It took:
Seconds : 1
Milliseconds : 174

And the line:
[sourcecode language=”powershell”]
get-view -ViewType virtualmachine -SearchRoot (get-cluster your_cluster).id -Filter @{‘Summary.Guest.ToolsVersionStatus’=’guestToolsNeedUpgrade’} | Select Name,@{N=’tools ver’;E={$_.Config.Tools.ToolsVersion}},@{N=’Tools Status’;E={$_.Summary.Guest.ToolsVersionStatus}}

So difference is 40 seconds 😉 Output is formatted like this
Name tools ver Tools Status
—- ———- ————
myvm1 8300 guestToolsNeedUpgrade
myvm2 8300 guestToolsNeedUpgrade
…… ….. ……………..

You may also like


C.Beerse June 29, 2018 - 3:38 pm

I bet the major profit is in using the string-compare (@{‘Summary.Guest.ToolsVersionStatus’=’guestToolsNeedUpgrade’}) in stead of the like-compare (?{$_.Extensiondata.Summary.Guest.ToolsVersionStatus -like ‘guestToolsNeedUpgrade’}).

What if you change the ‘like’ compare in the first line with the stirng compare (use “=” or “-eq”)? I bet that makes it somehow faster too.

psvmware June 29, 2018 - 5:52 pm

Hi there. That was not the point. Point was how to use the filter, which does server filtrr rather than downloading all the data and filter it on the client. Whatever you would do there you wouls ask server to send you all the data on which you are doing compare. It does not makw any sense to download all the data. Using views and filtera we are taking only that what we are interested in.


Leave a Reply

Chinese (Simplified)EnglishFrenchGermanHindiPolishSpanish