Updating VMware tools without reboot
A client was asking me if it was possible to install the VMware tools inside VM’s without having to reboot them right after. I knew it was possible and went looking for a way on doing so. During the search I found several scripts made by people which looked good (some out of date), but for most of them you had to made slight adjustments to the script to make them work for your own environment. The client wasn’t really looking for a script to maintain so I continued the search.
I ended up with just simply using the vSphere PowerCLI and a one line command for them to use. They can adjust the command line with some different parameters to select the scope of VM’s they want to target. The initial request was to upgrade the tools for a specific resource pool. The next command did this for them:
Get-ResourcePool “name resourcepool” | Get-VM | Update-Tools -noreboot
As you can see it’s a very basic command and can be easily used by any administrator. The downside of this method is that you need your vSphere PowerCLI stay connected during the executing of the entire process. Also the screen can get filled with error messages ranging from VM’s that are powered off or VM’s that are already up to date. Even though these errors occur the process will keep on continuing with the next VM in line.
In the example above you can see that the scope is set on a resource pool, but there are other options:
- Get-Cluster
- Get-Datacenter
- Get-vApp
In the case of this client they where planning to power down a datacenter which is hosting their test environment. As they would power down all the VM’s in the planned maintenance window, they used the command to update all the tools quickly without having to interrupt testing procedures of colleagues.
Note: As Duncan wrote in a article back in 2008, the reboot needed after updating the VMware tools isn’t for the tools itself, but for the OS that needs to load the new drivers.
So when you want to quickly update your VMware tools without a reboot, then you can use the command showing above. But if you want a command or script that can skip powered off or already up to date VM’s then you will have to search a bit further on the internet :)
Also feel free to reply any addition to the command or other example scripts.
Update: From Charl Pels I received the following command
Get-VM | where-object {$_.powerstate -eq “PoweredON”} | % {get-view $_.ID} | where {$_.guest.toolsstatus -match “toolsOld” } | Update-Tools -noreboot
This command should only update those servers that are currently powered on and have a older version of the VMware tools. Thank you Charl for providing this command.