One of the most powerful and versatile VM management capability in vSphere is the Guest Operations API, providing a rich set of operations from transferring files to/from the guest to running commands directly on the guest as if you were logged in!
An easy way to consume the Guest Operations API is via PowerCLI and using the Invoke-VMScript cmdlet, which I have extensively written about, showcasing all the creative ways this can be used to solve various automation challenges.
I recently came across a Reddit thread where the OP wanted to check to query for a specific VMware Tools configuration as part of the vSphere Security Configuration Guide and was looking for some help as logging into each and every system did not seem like a good idea, which it is NOT! 🙂
Any time you have a use case where you need to scale a specific operation (reading or writing) a change, you should consider Guest Operations API, you can easily use a single API to perform this operation at scale!
The command the OP was looking to run on a Windows Guest is the following: C:\Program Files\VMware\VMware Tools\VMwareToolboxCmd.exe config get autoupgrade allow-add-feature
Note: Guest Operations API can be used for any GuestOS that has VMware Tools installed and is not limited to just Windows-based OSes
Here is an example of using Invoke-VMScript to run the exact same command and of course, you will need proper guest credentials and then we can easily save the output to a variable name $results to then access for further processing:
$results = Invoke-VMScript -VM $vm -GuestUser "VMware" -GuestPassword "VMware1!" -ScriptText '"C:\Program Files\VMware\VMware Tools\VMwareToolboxCmd.exe" config get autoupgrade allow-add-feature' -ScriptType Bat $results.ScriptOutput
Here is the output after running the above snippet and we get the exact same value as
Thanks for the comment!