VMware tools upgrade script modification

Welcome Forums General PowerShell Q&A VMware tools upgrade script modification

This topic contains 2 replies, has 2 voices, and was last updated by

2 years, 8 months ago.

  • Author
  • #46402

    Points: 11
    Rank: Member

    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.

    Script below:
    #add this line so powershell knows to treat this as powerCLI
    add-pssnapin VMware.VimAutomation.Core

    $Server = ""
    $user = ""
    $pwd = ""
    $date = get-date

    $connect = Connect-VIServer $server -User $user -Password $pwd

    #Import vm name from csv file
    Import-Csv deploy.csv |
    foreach {
    $strNewVMName = $_.name

    #Update VMtools without reboot
    Get-VM $strNewVMName | Update-Tools -RunAsync
    write-host "Updated $strNewVMName —— "

    $report += $strNewVMName+ "`r`n"
    write-host "Sleeping ..."
    Sleep 60

    #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.


  • #46405

    Points: 0
    Rank: Member

    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.

  • #47075

    Points: 11
    Rank: Member

    Thanks. Let me have a look.


The topic ‘VMware tools upgrade script modification’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort