LucD wrote:
You should use a nested ForEach loop, where the inner loop runs over the VMKernel NICs for each host.
&{foreach($esxin (Get-VMHost|Sort-Object-PropertyName)){
Get-VMHostNetworkAdapter-VMHost$esx-VMKernel|
Select@{N="Name,";E={$esx.Name}},
@{N="Datacenter";E={Get-Datacenter-VMHost$esx|Select-ExpandPropertyName}},
@{N="Type";E={$esx.ExtensionData.Hardware.SystemInfo.Vendor+" "+$esx.ExtensionData.Hardware.SystemInfo.Model}},
@{N="CPU";E={"PROC:"+$esx.ExtensionData.Hardware.CpuInfo.NumCPUPackages+"Cores:"+$esx.ExtensionData.Hardware.CpuInfoNumCpuCores+"MHZ:"+ [math]::round($esx.ExtensionData.Hardware.CpuInfo.Hz/1000000,0)}},
@{N="MEM";E={""+[math]::round($esx.Hardware.MemorySize/1GB,0) +"GB"}},
@{N="NIC";E={$_.Name}},
IP,Subnetmask
}} |Export-Csvc:\hostinfo.csv-NoTypeInformation-UseCultureNote that the script uses the call operator (&) to get the objects, produced by the Select-Object cmdlet, on the pipeline.
LucD: What browser/tools do you use to post such beautifully formatted code?