VMware Cloud Community
aryan14in
Enthusiast
Enthusiast

upgrade/install vmware tool on 300+ windows (w2000/2003/2008/linux) VM

Hi guys- I have a task to move 300+ VMs from ESX3.5 to ESX4.0 and update tools in all guests after move is completed. The guests have mix bag of OS-windows 2000/2003/2008/linux/unix. Some of the VMs would need fresh installation of vmware tools and some would need upgrade. If it is only possible to provide script for windows, that would also work for me right now as majority of servers are windows.

I have gone through many forum discussion but nothing seems to be working for me. Can someone help with a script to acheive what I want to do.

I have downloaded latest powercli

Thanks!

0 Kudos
15 Replies
RvdNieuwendijk
Leadership
Leadership

You can install/upgrade VMware tools on all your virtual machines with the following PowerCLI script:

Get-VM | Get-View | `
Where-Object {$_.Guest.ToolsVersionStatus -ne "guestToolsCurrent"} | `
ForEach-Object {$_.UpgradeTools_Task("")}

Regards, Robert

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
0 Kudos
aryan14in
Enthusiast
Enthusiast

Hi Robert- Thanks!. could you please suggest how i can do on selected guests. My cluster has other servers which i don't want to touch. Is it possible to pass specific guest VM names for upgrade/install.

0 Kudos
RvdNieuwendijk
Leadership
Leadership

If you want to install/upgrade the VMware Tools only on certain VM's you can add the VM name behind the Get-VM cmdlet on the first line of the script. Like:

Get-VM MyVM1,MyVM2,MyVM3 | Get-View | `

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
0 Kudos
aryan14in
Enthusiast
Enthusiast

I modified the script as follows for one VM and executed it. But it failed saying "Cannot complete the opereation because vmware tool is not running on machine"

Get-VM vmname |Get-View |
Where-Object {$_.Guest.ToolsVersionStatus -ne "guestToolsCurrent"} | `
ForEach-Object {$_.UpgradeTools_Task("")}

-Vinod

0 Kudos
aryan14in
Enthusiast
Enthusiast

Just tried on a VM with old tools. Script failed with status "Error upgrading VMware Tools". This is windows 2008 VM. I tried from powercli

[vSphere PowerCLI] C:\update-tools vmname -noreboot

This failed as well with same error.

0 Kudos
satish_lx
Enthusiast
Enthusiast

Check out this:  http://communities.vmware.com/thread/256191

- If you found this information useful, please consider awarding points for "Correct" or "Helpful". Thanks!!! Thanks Satish Patel - Journey toward "Virtual world"
0 Kudos
satish_lx
Enthusiast
Enthusiast

Also checkout few more things: http://kendrickcoleman.com/index.php?/Tech-Blog/error-upgrading-vmware-tools-vsphere-41.html

- If you found this information useful, please consider awarding points for "Correct" or "Helpful". Thanks!!! Thanks Satish Patel - Journey toward "Virtual world"
0 Kudos
aryan14in
Enthusiast
Enthusiast

Could you please suggest how can i test the script on below link for specific VM. I want to pass on a servername.txt file to script.

http://get-admin.com/blog/scripting/powershell-scripting/powercli-update-vmware-tools-without-a-rebo...

0 Kudos
aryan14in
Enthusiast
Enthusiast

Also-most of blogs talk about upgrading tools. Can you direct me to script for installing tools?

0 Kudos
satish_lx
Enthusiast
Enthusiast

I never tried this script because we have different envirnment. But if you able to upgrade one VM then rest would be easy.

- If you found this information useful, please consider awarding points for "Correct" or "Helpful". Thanks!!! Thanks Satish Patel - Journey toward "Virtual world"
0 Kudos
aryan14in
Enthusiast
Enthusiast

Do you have a method to install (not update) tools on windows/linux VMs.

Thanks!

Vinod

0 Kudos
aryan14in
Enthusiast
Enthusiast

I meant how can I make this script to use a csv file containing my VM names.

If you want to install/upgrade the VMware Tools only on certain VM's you can add the VM name behind the Get-VM cmdlet on the first line of the script. Like:

Get-VM MyVM1,MyVM2,MyVM3 | Get-View | `

0 Kudos
mrksiddiqui
Enthusiast
Enthusiast

Use Import-CSV commandlet.

$myVM= Import-CSV "C:\vm.csv"
If this helps answer your question please consider awarding points!
0 Kudos
aryan14in
Enthusiast
Enthusiast

I am new to powershell, could you please put this in script. Thanks!

0 Kudos
mrksiddiqui
Enthusiast
Enthusiast

OK. I am not sure which script you may reffering too run but here is a smiple foreach loop. Main thing is get $VM.Name would return the list of machine.

CSV :

Name

VM1

VM2

VM3

Vm4

foreach ($VM in (Import-Csv -Path "c:\vmlist.csv"))
{
  Get-View -ViewType "VirtualMachine" `
  -Property Name,Guest `
  -Filter @{"Name"=$VM.Name;
       "Guest.GuestFamily"="windowsGuest";
      "Guest.GuestState"="running"}
}

Hope this helps.

If this helps answer your question please consider awarding points!
0 Kudos