VMware Cloud Community
vmhyperv
Contributor
Contributor
Jump to solution

VMware Tools upgrade for multiple VMs through power Cli

Hi,

I am looking for upgrading vmware tools for multiple VMs through scripts.Like VM1,VM2,Vm3,....................VM50.

Update-Tools -VM VM1 -NoReboot   (Its applicable only for Single VMs)

Any help will be appreciated in this as i have to upgrade around 100 VMs which was migrated from ESX3.5 to ESXi4.1

Thanks

VMguys

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

The Update-Tools cmdlet has a NoReboot parameter.

When you set that switch, there normally shouldn't be a reboot after the upgrade.

Get-VM -Name (1..50 | %{"VM$_"}) | Update-Tools -NoReboot

If you set the switch to $false, there will be a reboot if required.

Get-VM -Name (1..50 | %{"VM$_"}) | Update-Tools -NoReboot:$false

Note that this method of first creating an array with all the VM names you want, is faster than the previous example I gave.

In this case you only need to do one Get-VM with all the names, instead of 50 individual ones.


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

View solution in original post

0 Kudos
9 Replies
LucD
Leadership
Leadership
Jump to solution

You can use a pipeline construct.

Something like this

1..50 | %{Get-VM -Name VM$_} | Update-Tools -Confirm:$false


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

vmhyperv
Contributor
Contributor
Jump to solution

Thanks LucD  for help.I will let you know once i execute this in office environment.So i have question on this .Will this command execute  without VM re-boot or it will re-boot the vms after upgrade. I want for  both cases.

Thanks

vmguys

0 Kudos
LucD
Leadership
Leadership
Jump to solution

The Update-Tools cmdlet has a NoReboot parameter.

When you set that switch, there normally shouldn't be a reboot after the upgrade.

Get-VM -Name (1..50 | %{"VM$_"}) | Update-Tools -NoReboot

If you set the switch to $false, there will be a reboot if required.

Get-VM -Name (1..50 | %{"VM$_"}) | Update-Tools -NoReboot:$false

Note that this method of first creating an array with all the VM names you want, is faster than the previous example I gave.

In this case you only need to do one Get-VM with all the names, instead of 50 individual ones.


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

0 Kudos
vmhyperv
Contributor
Contributor
Jump to solution

LucD,

  Similar like other thread,I want to upgrade at cluster level.

"As if we have 15 cluster in the environment and i want to upgrade the vmware tools  of a particular 20 vms at Cluster level say Cluster2 where i have 20  vms (vm1,vm2,vm3 ....) which recently migrated from ESX3.5 to ESXi4.1 Then what would be the change in script for cluster wise because we are upgrading clusterwise from ESX3.5 to ESX4.1"  Where we down time for that particular cluster.(With Re-boot and No-Re-boot both)

Thanks

vmguys

0 Kudos
LucD
Leadership
Leadership
Jump to solution

The selection of the VMs would change like this

Get-Cluster -Name Cluster2 | Get-VM |
Update-Tools -NoReboot:$false


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

vmhyperv
Contributor
Contributor
Jump to solution

Execellent !!

Thanks  LucD  i will let you know once executed.

vmguys

0 Kudos
mburutzis
Contributor
Contributor
Jump to solution

Is there a way to pick a list of VM either from a file or something to selectively update them?  Also, what is required to delegate permissions for one to update the vmtools from CLI?

0 Kudos
LucD
Leadership
Leadership
Jump to solution

You can import a CSV file with the Import-Csv cmdlet.

To update tools you need the VirtualMachine.Interact.ToolsInstall privilege.


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

0 Kudos
mburutzis
Contributor
Contributor
Jump to solution

Thanks LucD, works like a charm!

0 Kudos