8 Replies Latest reply on May 6, 2019 9:43 PM by ThompsG

    How to check VMware Tools status of VM use PowerCLI

    as900w Enthusiast

      I want to writer a script to shutdown VM.


      Use Connect-VMServer connection to vCenter Server:

      $credential = Get-Credential

      Connect-VIServer -Server <vCenter Server FQDN or IP> -Credential $credential


      Use Get-VM to get VM list  that power state is PoweredOn

      Get-VM | Where-Object{$_.PowerState -eq "PoweredOn"} | Export-Csv -Path C:\VMList.csv -NoTypeInformation

      $VMList = Import-Csv -Path C:\VMList.csv

      ( I want to combine these two statements,but it's failed. )


      I want to check the  VMware Tools atatus of VM in the $VMList.

      What should I do?


      I want to use "if and else" statement:

      If Tools status is OK, using Shutdown-VMGuest to Shut down VM.

      slse using stop-VM to shut down VM

      What should I do?