PowerCLI – Upgrading VMtools without rebooting a Virtual Machine

VMware Tools is a suite of utilities that enhances the performance of the virtual machine’s guest operating system and improves management of the virtual machine. Without VMware Tools installed in your guest operating system, guest performance lacks important functionality. Whenever there is a new upgrade performed on ESX/ESXi host the latest version of VMtools will also be available on the hosts which can be installed on Virtual machines.

Performing VMtools upgrade in a large environment manually is a little bit difficult task and the virtual machine will be rebooted multiple times during VMtools upgrade process.

There is another way to perform VMtools upgrade by enabling options on Virtual Machine to check and perform upgrade of VMtools during reboot process however enabling this option might cause VMtools upgrade on a production Virtual machine after there is a heart beat loss between Host and VM causing downtime to production applications during business hours.

I have written a script using PowerCLI which can be used to upgrade the VMtools on multiple virtual machines without rebooting them and this script connects to vCenter then looks for the VMs specified in a text file however during upgrade you’ll observe there will be 3-4 ping request time-outs to the virtual machine and the VMware tools service will be restarted.

Below are steps to execute this PowerCLI script for upgrading VMware tools on virtual machine without reboot

1) Login to VCenter server open Power-CLI command line
2) At PowerCLI traverse to the folder where the PSC-VMToolsUpgd.ps1 is saved/copied
3) Mention the virtual machine names in VMnames.txt file on which VMware tools upgrade is to be performed
4) Make sure you save the VMnames.txt in same folder as PSC-VMToolsUpgd.ps1
5) Now call PSC-VMToolsUpgd.ps1 script at Power-CLI command prompt
6) The script will ask for VCenter server name to connect, we need to provide the correct VCenter name where the VMs are present else the script will not be able to find the Virtual machines listed in VMnames.txt

001

 

 

 

7) Once the PowerCLI script is executed it will look for each VM one by one mentioned in VMnames.txt and then it will perform VMware tools upgrade without reboot, a vmtools upgrade status bar will be shown in the PowerCLI command prompt

002

8) You can also see a recent task initiated in VCenter console

003
9) During VMware tools upgrade the Virtual machine will have two ping timeouts however two ping timeout will not cause production server issues and the VMware tools will get upgraded without any reboot
Note: For virtual machine with windows 2003 OS will not show any ping timeouts

004

 

10) After VMware tools upgrade the PowerCLI script will display a message stating the VMware tools upgrade completed with virtual machine name, and you can also see recent completed task in VCenter

005

 

006
11) After upgrade of VMware tools don’t forget to check DNS record for the virtual machine by doing nslookup

———————– PSC-VMToolsUpgd.ps1 script content ———————–

# PSC-VMToolsUpgd.ps1 Power-CLI script to upgrade VMware tools without reboot
# Mention the virtual machine names in VMnames.txt files and save it in same folder as PSC-VMToolsUpgd.ps1
# Interactive script that asks for vCenter server name
# Script also searches for VM in vCenter and then performs the upgrade
# If the vm is not present in vCenter a message will be displayed on the screen

$ErrorActionPreference = “SilentlyContinue”
$vcname = Read-host “Enter the vCenter or Esxi host name to connect”
Connect-viserver $vcname
foreach ($computers in Get-Content “VMnames.txt”)
{
$Temp = Get-VM $computers
If($Temp -match $computers)
{
Get-VM $Temp | Update-Tools -NoReboot
write-host “VMtools upgrade on $Temp completed”
}
else
{
write-host ” $computers virtual machine is not present in vCenter”
}
}
Disconnect-viserver -Confirm:$false

———————– PSC-VMToolsUpgd.ps1 script content ———————–

Advertisements

About asifkhandevadi

Hello, I have been working on windows since 9 years and currently working as windows, VMware and MS clustering SME at IBM. Whenever I get free time I participate in Microsoft forums and write some blogs to enhance my technical and communication skills through knowledge sharing. Please contact me on FB or Linkedin if you need any assistance on troubleshooting, implementation and virtualizaton.
This entry was posted in PowerCLI, VMtools, VMware and tagged . Bookmark the permalink.

3 Responses to PowerCLI – Upgrading VMtools without rebooting a Virtual Machine

  1. Ankoji says:

    Hi Asif,

    Thanks for nice script. But is it possible to get the report thru email which VM got updated the VMware tools.

    Like

  2. anksos says:

    Is this working to VMware 5.5?

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s