Quantcast
Channel: VMware Communities : Blog List - All Communities
Viewing all articles
Browse latest Browse all 3135

PowerCLI - Update VMware Tools without reboot

$
0
0

There are many articles on the web about how to update VMware Tools of virtual machines, without a reboot. Here is my take on it. Simple, dirty code.

 

  • First a CSV file (deploy.csv) containing list of servers to be updated.

 

name
vmserver01
vmserver02
vmserver03
vmserver04
vmserver05
vmserver06
vmserver07
vmserver08
vmserver09
vmserver10

 

  • And here is the actual Powershell script, I run it from vSphere PowerCLI. To run from  Windows Powershell, add "Add-PSSnapin VMware.VimAutomation.Core" at the beginning of the code. After updating the vms, it sends out an email with the list of vms updated. Get-Cluster <cluster name> portion can be skipped, if there is only one cluster.

 

#Connect to vcenter server
connect-viserver <vcenter name>
#Import vm name from csv file
Import-Csv deploy.csv |
foreach {    $strNewVMName = $_.name       #Update VMtools without reboot    Get-Cluster <cluster name> | Get-VM $strNewVMName | Update-Tools –NoReboot   write-host "Updated $strNewVMName ------ "        $report += $strNewVMName
}
write-host "Sleeping ..."
Sleep 120
#Send out an email with the names
$emailFrom = "<sender email id>"
$emailTo = "<recipient email id>"
$subject = "VMware Tools Updated"
$smtpServer = "<smtp server name>"
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$smtp.Send($emailFrom, $emailTo, $subject, $Report)

Viewing all articles
Browse latest Browse all 3135

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>