VMware Cloud Community
G0nz0UK
Enthusiast
Enthusiast

Possible to export our vCenter Inventory to CSV?

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

0 Kudos
11 Replies
LucD
Leadership
Leadership

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

0 Kudos
G0nz0UK
Enthusiast
Enthusiast

Searching now, thanks.

0 Kudos
LucD
Leadership
Leadership

If you get stuck on one or more of those properties, let us know.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
G0nz0UK
Enthusiast
Enthusiast

 

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
0 Kudos
G0nz0UK
Enthusiast
Enthusiast

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

}
0 Kudos
LucD
Leadership
Leadership

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

0 Kudos
G0nz0UK
Enthusiast
Enthusiast

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.

 
 
0 Kudos
LucD
Leadership
Leadership

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

G0nz0UK
Enthusiast
Enthusiast

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.

0 Kudos
G0nz0UK
Enthusiast
Enthusiast

Just one last thing, is it possible to add the EVC mode in that list too?

0 Kudos
LucD
Leadership
Leadership

You can add a property

EVCMode = (Get-Cluster -VMHost $esx).EVCMode


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference