Hello,
We have 48 hosts in our vCenter across 4 Clusters.
Is it possible to export this inventory to csv so it it includes attributes like:
Cluster name,Host name, Hypervisor (for example VMware ESXi, 7.0.3, 19193900), model, Processor Type, Logical Processors, Nics, Serial Number, state, status, ha, uptime, version, no vms.
Basically a one stop table, I am to then push to Influxdb or Grafana.
Thanks
If you do a search in this community you should find solutions for retrieving most, if not all, of these properties.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Searching now, thanks.
If you get stuck on one or more of those properties, let us know.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Using this I tried myself, I just need to get the rest of the attributes:
Get-VMHost | select name, connectionstate, powerstate, numcpu, version | Export-Csv C:\vmware\powercli\reports\vmhostinfov1.csv -NoTypeInformation
I'm managed to find 2 scripts that work independently, but I'm not sure how to merge into one table. I still need to find the other attributes, but getting closer:
Get-VMHost | select name, connectionstate, powerstate, numcpu, version | Export-Csv C:\vmware\powercli\reports\vmhostinfov1.csv -NoTypeInformation
and
foreach($esxcli in Get-VMHost | Get-EsxCli -V2){
$esxcli.hardware.platform.get.Invoke() |
Select @{N='VMHost';E={$esxcli.VMHost.Name}},VendorName,ProductName,SerialNumber
}
You could do something like this to combine them
Get-VMHost -PipelineVariable esx |
ForEach-Object -Process {
$esxcli = Get-EsxCli -VMHost $esx -V2
$platform = $esxcli.hardware.platform.get.Invoke()
[PSCustomObject]@{
Name = $esx.Name
Cluster = (Get-Cluster -VMHost $esx).Name
ConnectionState = $esx.ConnectionState
PowerState = $esx.PowerState
NumCPU = $esx.NumCpu
Version = $esx.Version
VendorName = $platform.VendorName
ProductName = $platform.ProductName
SerialNumber = $platform.SerialNumber
}
} | Export-Csv C:\vmware\powercli\reports\vmhostinfov1.csv -NoTypeInformation -UseCulture
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Oh yes this is wonderful!
Do you know where or how I can get the other attributes, I'm sure there is a long list of other nice attributes to add to the table that I can source or lookup, for example:
No. Nics, status, ha, uptime, no vms, Processor Type, bios version, total memory, processor speed, processor sockets, processor cores per socket, hyperthreading status, etc.
Just looking through vCenter.
Like I said, most of these properties are already discussed in this community.
Just for info, I added a few more, so you can check how it is done.
Get-VMHost -PipelineVariable esx |
ForEach-Object -Process {
$esxcli = Get-EsxCli -VMHost $esx -V2
$platform = $esxcli.hardware.platform.get.Invoke()
$cpu = $esxcli.hardware.cpu.global.get.Invoke()
[PSCustomObject]@{
Name = $esx.Name
Cluster = (Get-Cluster -VMHost $esx).Name
ConnectionState = $esx.ConnectionState
PowerState = $esx.PowerState
NumCPU = $esx.NumCpu
Version = $esx.Version
VendorName = $platform.VendorName
ProductName = $platform.ProductName
SerialNumber = $platform.SerialNumber
NoNic = $esxcli.network.nic.list.Invoke().Count
Status = $esx.State
HA = $esx.ExtensionData.Summary.Runtime.DasHostState.State
Uptime = ((Get-Date) - $esx.ExtensionData.Runtime.BootTime).ToString("dd' days 'hh' hours 'mm' minutes 'ss' seconds'")
NoVM = $esx.ExtensionData.VM.Count
BIOSVersion = $esx.ExtensionData.Hardware.BiosInfo.BiosVersion
BIOSVendor = $esx.ExtensionData.Hardware.BiosInfo.Vendor
BIOSReleaseDate = $esx.ExtensionData.Hardware.BiosInfo.ReleaseDate
Processor = $esx.ExtensionData.Hardware.CpuPkg[0].Description
MemoryGB = $esx.MemoryTotalGB
ProcSpeedGhz = [math]::Round($esx.ExtensionData.Hardware.CpuInfo.Hz/(1000*1000*1000),1)
ProcSockets = $cpu.CPUPackages
ProcCoresPerSocket = $cpu.CPUCores / $cpu.CPUPackages
HTStatus = if($cpu.HyperthreadingActive){'Active'}else{'Not Active'}
}
} | Export-Csv C:\vmware\powercli\reports\vmhostinfov1.csv -NoTypeInformation -UseCulture
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
This is totally unbelievable, thank you!
I'm not sure what other attributes I'm missing that could be useful, but so much info pulled.
Just one last thing, is it possible to add the EVC mode in that list too?
You can add a property
EVCMode = (Get-Cluster -VMHost $esx).EVCMode
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference