PowerCLI

 View Only
  • 1.  Getting the power state of a VM

    Posted Mar 21, 2017 04:00 PM

    I apologize for the very basic question.

    How can I get the power status of a VM?

    I made several tests but up to now I was unable to find the right syntax...

    Regards

    marius



  • 2.  RE: Getting the power state of a VM
    Best Answer

    Posted Mar 21, 2017 04:18 PM

    This should do it:

    Get-VMHost "host" | Get-VM | Where-Object  {$_.PowerState -eq "PoweredOn"}



  • 3.  RE: Getting the power state of a VM

    Posted Mar 21, 2017 05:22 PM

    The PowerState is a property that is present in the VirtualMachine object that is returned by the Get-VM cmdlet.

    With the Select-Object cmdlet you specify the properties you want to display.

    Get-VM | Select Name,PowerState