BrianGordon84
Contributor
Contributor

Update-Tools

I'm having a few problems with the update-tools cmdlet. Can anyone tell me what is wrong with this script or post yours if you have one?

I basically want it to only update vm's with out of date tools, not try to update all of them no matter what. I get an error saying the requested operation could not be performed on this object. When I ran update-tools -vm vmname by itself from the command line it worked perfectly, no issues.

param($esx)

$vmObj = Get-VM -Location $esx

foreach($vm in $vmObj){
if($vm.ExtensionData.Guest.ToolsVersionStatus -match "guestToolsNeedUpgrade"){Update-Tools -VM $vm -NoReboot -ErrorAction SilentlyContinue}
}

0 Kudos
5 Replies
LucD
Leadership
Leadership

Your script looks good and seems to work without a problem in my test environment.

Which PowerCLI version are you using and on which vCenter/ESX versions are your guests running ?

Could you perhaps also include the full error message as you see it on the console ?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
bulletprooffool
Champion
Champion

Works fine for me too.

Do you have multiple ESX hosts and is it perhaps only failing when updating VMs on a particular hist (perhaps the ISO is missing from the ESX host?)

try updating a VM on each ESX host manually - see if they all work.

Also, the tools differ for different VM client types - could it be that only tools for some flavours of OS are available?

One day I will virtualise myself . . .
0 Kudos
BrianGordon84
Contributor
Contributor

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?

0 Kudos
LucD
Leadership
Leadership

Could it be that the guests where you get the "not supported" message are running a VMware Tools version that corresponds with ESX 2.5 ?

That is a known problem and the only solution seems to be a manual upgrade for those.

An extract from the VMware vCenter Update Manager Release Notes

"VMware Tools Upgrade Fails for Virtual Machines Created on Hosts of Versions 2.5.x When you scan a virtual machine with the VMware Tools version corresponding to ESX 2.5.x against a VMware Tools Upgrade to Match Host baseline, the VMware Tools Upgrade to Match Host baseline state is Non-Compliant. Although the state is noncompliant, the VMware Tools upgrade fails with a VM Tools installed in the VM doesn't support automatic upgrade error message. Automatic upgrade for VMware Tools is supported only for virtual machines created on hosts running versions ESX 3.0.x, ESX 3.5 or higher, and ESX 3i version 3.5 or higher. Workaround: Upgrade VMware Tools manually by right-clicking the virtual machine in the inventory and selecting Guest > Install/Upgrade VMware Tools."


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
BrianGordon84
Contributor
Contributor

One particular VM it failed on is actually running ToolsVersion 8194. 

0 Kudos