Running vCenter Server v4.0.0 build 208111
This particular esx host that im running this against is running ESX 4.0.0, 261974
PowerCLI Version 4.1 U1 Build 332441
The full error message is: The operations is not supported on the object. (not a very helpful error message)
I have multiple esx hosts, yes, but I'm only running it against one (the one I've posted version info for here)
I did notice that when I ran this script, the first vm it grabbed was a windows 2008 vm. So I modified the script like this:
if($vm.ExtensionData.Guest.ToolsVersionStatus -match "guestToolsNeedUpgrade" -and $vm.Guest.OSFullName -like "*2003*"){Update-Tools -VM $vm -NoReboot -ErrorAction SilentlyContinue}
In hopes of only running this for windows 2003 vm's.
I also added the following code:
$vmObj = Get-VM -Location $esx | Sort-Object
I was hoping it would start at the top of the list but instead it seems to just randomly grab one in the list. I know this command sorts perfectly as I went into the cli and ran this command by itself and could see the objects were all sorted correctly.
The full modified script looks like this:
param($esx)
$vmObj = Get-VM -Location $esx | Sort-Object
foreach($vm in $vmObj){
if($vm.ExtensionData.Guest.ToolsVersionStatus -match "guestToolsNeedUpgrade" -and $vm.Guest.OSFullName -like "*2003*"){Update-Tools -VM $vm -NoReboot -ErrorAction SilentlyContinue}
}
I'm able to manually update the vm's with no problem. They all work. Any other suggestions, thoughts?