… that looks weird … how do you populate $esx? Using the same variable for the loop itself and defining it inside the loop cannot work. ![]()
What is it actually what you want to achieve? If you want to get information about each individual VMHost of a given cluster you may run something like this:
Get-Cluster -Name "swbdvcpyld01v.nslijhs.net" |
Get-VMHost |
ForEach-Object {
$VMHostNetworkAdapter = Get-VMHostNetworkAdapter -VMKernel -VMHost $_
$VMHostNetworkStack = Get-VMHostNetworkStack -VMHost $_
[PSCustomObject]@{
Hostname = $VMHostNetworkAdapter.VMHost
IP = $VMHostNetworkAdapter.IP
IPv6Enable = $VMHostNetworkStack.IPv6Enabled
DnsAddress = $VMHostNetworkStack.DnsAddress
}
}
!! You may adapt the queries inside the loop. You don’t provide the VMHost via pipeline - so you have to specify it.