You are on page 1of 1

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)

You might also like