Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 192300

Re: Help with script

$
0
0

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?


Viewing all articles
Browse latest Browse all 192300

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>