Quantcast
Viewing all articles
Browse latest Browse all 181285

Re: Help with script

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-UseCulture

Note 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? Image may be NSFW.
Clik here to view.


Viewing all articles
Browse latest Browse all 181285

Trending Articles