With PowerCLI, you can get information about all available hosts in a data center and view their properties.

Prerequisites

Verify that you are connected to a vCenter Server system.

Procedure

  1. Get a list of all hosts that are part of a data center.
    Get-Datacenter DC | Get-VMHost | Format-Custom
  2. View the properties of the first host in the data center.
    Get-Datacenter DC | Get-VMHost | Select-Object -First 1 | Format-Custom
  3. View the Name and the OverallStatus properties of the hosts in the DC data center.
    Get-Datacenter DC | Get-VMHost | Get-View | Format-Table -Property Name, OverallStatus -AutoSize
  4. View all hosts and their properties, and save the results to a file.
    Get-Datacenter DC | Get-VMHost | Format-Custom | Out-FileFilePath hosts.txt
  5. View a list of the hosts that are in maintenance mode and can be configured for vMotion operations.
    Get-VMHost -State maintenance | Get-View | Where-Object -FilterScript { $_.capability -ne $null -and $_.capability.vmotionSupported }