- July 9, 2016 at 12:36 pm #46402
I have 50 vm machines, I add all 50 machines to a file and run powershell script. But output comes saying all 50 machines upgraded.
#add this line so powershell knows to treat this as powerCLI
$Server = ""
$user = ""
$pwd = ""
$date = get-date
$connect = Connect-VIServer $server -User $user -Password $pwd
#Import vm name from csv file
Import-Csv deploy.csv |
$strNewVMName = $_.name
#Update VMtools without reboot
Get-VM $strNewVMName | Update-Tools -RunAsync
write-host "Updated $strNewVMName —— "
$report += $strNewVMName+ "`r`n"
write-host "Sleeping ..."
#Send out an email with the names
$emailFrom = ""
$emailTo = ""
$subject = "VMware_Tools_Updated & Machines Got Rebooted"
$smtpServer = ""
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$smtp.Send($emailFrom, $emailTo, $subject, $Report)
My requirement is, i will add all 50 vm's to deploy.csv and run the script. It should upgrade on the vm servers which require vm tools upgrade and give me output only upgraded servers names. And i need output which vm servers tool upgrade failed as-well.
-KalyanJuly 9, 2016 at 2:03 pm #46405
You forgot for inspect the current state to see which need upgrades.
There is a property somewhere in the output of get-vm that tells you version status. Evaluate it.July 15, 2016 at 5:02 pm #47075
Thanks. Let me have a look.
You must be logged in to reply to this topic.