VMware Cloud Community
srnagu
Contributor
Contributor
Jump to solution

Script to update VMware tools in Windows VMs-- ESXi 3.5

Hi,

We have ESXi 3.5 server in which we have windows and Linux VMs hosted.

Is it possible to update the VMtools of Windows VMs through any script?

In our VC server we have VI toolkit 1.0 installed

Reply
0 Kudos
1 Solution

Accepted Solutions
alanrenouf
VMware Employee
VMware Employee
Jump to solution

Well if thats the case then its as simple as the below:

Connect-viserver "MyVIServer"

Get-VMHost "myhost.mydomain.com" | get-vm | Update-Tools

If you found this information useful, please consider awarding points for Correct or Helpful.

Alan Renouf

Blog: http://virtu-al.net Twitter: http://twitter.com/alanrenouf Co-author of the PowerCLI Book: http://powerclibook.com

View solution in original post

Reply
0 Kudos
8 Replies
alanrenouf
VMware Employee
VMware Employee
Jump to solution

Have you read this previous post ?

http://communities.vmware.com/thread/151936

Blog: http://virtu-al.net Twitter: http://twitter.com/alanrenouf Co-author of the PowerCLI Book: http://powerclibook.com
srnagu
Contributor
Contributor
Jump to solution

Hi,

Thanks.. I had missed to see that post.

I think, below script will upgrade all the VMs in the VC

Get-VIServer -Server <VC server>

$ToolsCurrent = <target Tools version>

Get-Content target-vms.txt | %{Get-VM -Name $_} | %{$vm = $_; Get-View $_.ID} | `

%{if($_.config.tools.toolsVersion -eq 0 -or $_.config.tools.toolsVersion -lt $ToolsCurrent) {Update-Tools -VM $vm} }

Can we install only few VMs at a time?

In our environment we have around 20 ESXi 3.5 server in which there are around 450VMs hosted. We guess it is worth doing one by one ESXi host as we cant get downtime of all VMs at a time.

Is it possible to modify above script (or write some new) to meet my requirement?

Reply
0 Kudos
alanrenouf
VMware Employee
VMware Employee
Jump to solution

That code reads the entries from a text file and updates only those vms, to do a host at a time you should be able to do:

Get-VIServer -Server <VC server>

$ToolsCurrent = <target Tools version>

$ESXHost = "Host1.mydomain.com"

Get-VMHost -Name $ESXHost | %{Get-VM | %{$vm = $_; Get-View $_.ID} | `

%{if($_.config.tools.toolsVersion -eq 0 -or $_.config.tools.toolsVersion -lt $ToolsCurrent) {Update-Tools -VM $vm} }

If you found this information useful, please consider awarding points for Correct or Helpful.

Alan Renouf

VMware, Citrix, Microsoft Consultant

UK

Blog: http://virtu-al.net Twitter: http://twitter.com/alanrenouf Co-author of the PowerCLI Book: http://powerclibook.com
srnagu
Contributor
Contributor
Jump to solution

Sorry for awakardness Smiley Sad

Do we really need give the current version of the VMtools? In my case all the VMs has old VMtools as we have updated ESXi with BUILD158869 recently.

ToolsCurrent = <target Tools version>

Can we avoid this and update all the VMs hosted in the ESXi host? (since all the VMs tool status or old)

If I really need to give the current status, how to know the current version? (Before updating ESXi host, Earlier OS BUILD was 130755)

Reply
0 Kudos
alanrenouf
VMware Employee
VMware Employee
Jump to solution

Well if thats the case then its as simple as the below:

Connect-viserver "MyVIServer"

Get-VMHost "myhost.mydomain.com" | get-vm | Update-Tools

If you found this information useful, please consider awarding points for Correct or Helpful.

Alan Renouf

Blog: http://virtu-al.net Twitter: http://twitter.com/alanrenouf Co-author of the PowerCLI Book: http://powerclibook.com
Reply
0 Kudos
srnagu
Contributor
Contributor
Jump to solution

Ok. This is what I was looking for.

One final question? how to see the current version of VMtools?

Reply
0 Kudos
alanrenouf
VMware Employee
VMware Employee
Jump to solution

Connect-viserver"MyVIServer"

Get-VMHost "MyHost.mydomain.com" | Get-VM | Get-View | Select Name, @{N="ToolsVersion";E={$_.Config.Tools.ToolsVersion}}

or for all vms on all hosts:

Get-VM | Get-View | Select Name, @{N="ToolsVersion";E={$_.Config.Tools.ToolsVersion}}

If you found this information useful, please consider awarding points for Correct or Helpful.

Alan Renouf

http://virtu-al.net

Blog: http://virtu-al.net Twitter: http://twitter.com/alanrenouf Co-author of the PowerCLI Book: http://powerclibook.com
Reply
0 Kudos
IPF
Contributor
Contributor
Jump to solution

Any way of modifying the script to tell windows not to reboot after the install so we can reboot at a later date?

Reply
0 Kudos