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.