I have written a PowerCLI script that simplifies the process when upgrading VMware tools on all Servers in a Virtual Environment after a VMware version / patching version update.
Whist running the script, you will need to fill in the blanks with regards to vCenter name, Cluster name, and Email details.
Ensure you have the required version of PowerCLI installed before attempting to run this script.
# Upgrade of VMTools # Notes: Script to update VMtools by batch using a CSV file # By Ryan Mangan 03/06/2014 # # Connect to vcenter server Write-host "****** VMware Tools Upgrade Script ******" -foregroundcolor green add-pssnapin VMware.Vimautomation.core $vcenter = read-host "Enter the vCenter Instance" connect-viserver -Server $vcenter -WarningAction SilentlyContinue #Import vm name from csv file
$CSVLoc = read-host "enter CSV File location e.g c:\temp\deploy.csv" Import-Csv $CSVLoc | foreach { $strNewVMName = $_.name #Update VMtools without reboot $Clustername = Read-host "enter cluster name" Get-Cluster $Clustername | Get-VM $strNewVMName | Update-Tools –NoReboot write-host "Updated $strNewVMName ------ " $report += $strNewVMName } write-host "Sleeping ..." Sleep 120 #Send out an email with the names $SenderID = Read-host "enter email from address" $RecipEmailID = Read-host "enter repcipient email id" $EMAILSRV = Read-host "enter Email Server Name" $emailFrom = $SenderID $emailTo = $RecipEmailID $subject = "VMware Tools Updated" $smtpServer = $EMAILSRV $smtp = new-object Net.Mail.SmtpClient($smtpServer) $smtp.Send($emailFrom, $emailTo, $subject, $Report)
Thanks for posting, I will have to give it a try. One thing to mention is that the commented out header of your script talks about upgrading virtual machine hardware and making sure the VMs are powered off…
Hi Kevin,
Yes apologies for that, i have been working on a Hardware upgrade script as well. I must of copied the comments over from the script. I have now updated this.
thanks
HI?
I have a vCentre with multiple clusters. How do I modify the script to get vm’s from any cluster
you will need to edit the script to point to vcenter rather than a cluster, or create a script per cluster
what’s the format of the CSV file? dose the collum with the VM names just need the word ‘name’ at the top of the column.
Also
If your using vCloud director for many of the VM’s is this still the recommended method or should I be hitting vCD?
export the vms using powercli in csv format then use that to run the upgrade script