Originally published April 17, 2017 @ 11:14 am

Another simple one-liner to get a list of hostnames of all ESX servers in the vCenter. This can be useful for a number of things, specifically as input for other PowerCLI scripts.

Set-PowerCLIConfiguration -Scope Session -WebOperationTimeoutSeconds -1 -Confirm:$false;
Import-Module VMware.VimAutomation.Vds;
$VMHost="vcenter01.domain.com";
Connect-VIServer -Server $VMHost -User 'DOMAIN\User' -Password 'Password1';

Get-Datacenter | Get-VMHost | Get-View | Format-Table -Property Name -AutoSize | Out-File -FilePath C:
\esx_hosts.txt