Like MadMax01 suggests, run that powershell command via powercli.
I assume you got a list of vms with windows systems:
$WindowsVMS = get-view -viewtype virtualmachine -property 'name','guest.guestFamily' -filter @{'guest.GuestFamily'='windowsGuest'}
Then you invoke script on them . Assuming that in those boxes vmware tools are running of course.
Build a windows credential set before:
$credential = get-credential
foreach ($vm in $WindowsVMS){
$vm | select name, @{n='Edition';e={(Invoke-VMScript -GuestCredential $credential -ScriptType 'powershell' -ScriptText '(gwmi win32_operatingsystem).caption' -VM $vm.name).ScriptOutput} }
}
At the end you willl get nice report like
Name Edition
---- -------
myVM Microsoft Windows Server 2008 R2 Enterprise ...
Assuming that those credentials will match every vm it should be all ok. If not you have to try to run multiple times this script with different versions, and try implementing ifs on fault then use different set of credential.