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
- Get a list of all hosts that are part of a data center.
Get-Datacenter DC | Get-VMHost | Format-Custom
- View the properties of the first host in the data center.
Get-Datacenter DC | Get-VMHost | Select-Object -First 1 | Format-Custom
- 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
- View all hosts and their properties, and save the results to a file.
Get-Datacenter DC | Get-VMHost | Format-Custom | Out-File –FilePath hosts.txt
- 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 }