PowerCLI: Host Hardware One-Liner

A quick one-liner which gives you an outline of your Host hardware information:

Get-VMHost |Sort Name |Get-View |
Select Name,
@{N
=Type;E={$_.Hardware.SystemInfo.Vendor+ + $_.Hardware.SystemInfo.Model}},
@{N
=CPU;E={PROC: + $_.Hardware.CpuInfo.NumCpuPackages + CORES: + $_.Hardware.CpuInfo.NumCpuCores + MHZ: + [math]::round($_.Hardware.CpuInfo.Hz / 1000000, 0)}},
@{N
=MEM;E={“” + [math]::round($_.Hardware.MemorySize / 1GB, 0) + GB}} | Export-Csv c:\hostinfo.csv

Output Example:

Name Type CPU MEM
prod01.domain.local Dell Inc. PowerEdge 2950 PROC: 2 CORES: 8 MHZ: 2993 32 GB
prod02.domain.local Dell Inc. PowerEdge 2950 PROC: 2 CORES: 8 MHZ: 2993 32 GB
prod03.domain.local Dell Inc. PowerEdge 2950 PROC: 2 CORES: 8 MHZ: 2993 32 GB
prod04.domain.local Dell Inc. PowerEdge 2950 PROC: 2 CORES: 4 MHZ: 2993 16 GB
tst10.domain.local Dell Inc. PowerEdge 2950 PROC: 2 CORES: 8 MHZ: 2660 16 GB
tst11.domain.local Dell Inc. PowerEdge 2950 PROC: 2 CORES: 8 MHZ: 2660 16 GB
tst12.domain.local Dell Inc. PowerEdge 2950 PROC: 2 CORES: 8 MHZ: 2660 16 GB
tst13.domain.local Dell Inc. PowerEdge 2950 PROC: 2 CORES: 8 MHZ: 2992 32 GB
tst14.domain.local Dell Inc. PowerEdge 2950 PROC: 2 CORES: 8 MHZ: 2992 32 GB
tst15.domain.local Dell Inc. PowerEdge 2950 PROC: 2 CORES: 8 MHZ: 2992 32 GB
tst16.domain.local Dell Inc. PowerEdge 2950 PROC: 2 CORES: 8 MHZ: 2992 32 GB

20 thoughts on “PowerCLI: Host Hardware One-Liner

  1. Amjad

    How about adding number of VM’s per host to this? tried some samples form other commands but it would not work

    Here is what I tried but keep getting 0 for vm numbers

    Get-VMHost |Sort Datacenter | Get-View |
    Select @{N=”Datacenter”;E={Get-datacenter -VMHost $_.Name}}, Name,
    @{N=”Type“;E={$_.Hardware.SystemInfo.Vendor+ “ “ + $_.Hardware.SystemInfo.Model}},
    @{N=“CPU“;E={“PROC: “ + $_.Hardware.CpuInfo.NumCpuPackages}},
    @{N=“CORES“;E={“CORES: “ + $_.Hardware.CpuInfo.NumCpuCores}},
    @{N=”VMs”;E={($_|Get-VM).Count}}

  2. Jitu

    Hi All,

    Even after running the below command , I am not getting the output, there are no errors, but the output is blank. Please help me

    “@{N=“Type“;E={$_.Hardware.SystemInfo.Vendor+ “ “ + $_.Hardware.SystemInfo.Model}},”

  3. Lakshmanan V

    Hi I tried the SerialNumber, but its not working could someone give the correct script to generate SerialNumber of HP Blade Servers for 4.1 ESX hosts

  4. Lakshmanan V

    Hi I tried the SerialNumber, but its not working could someone give the correct script to generate SerialNumber of HP Blade Servers

  5. Romain Gaudin

    To get the serial number here is the line to change :
    @{N=“Serial Number“;E={(Get-EsxCli -VMHost $_.Name).hardware.platform.get().SerialNumber}},

  6. Balu

    Hi I tried the SerialNumber, but its not working could someone give the correct script to generate SerialNumber of HP Blade Servers

  7. Sathe

    Updated to include Datacenter Name

    Connect-VIServer vcententername -User xxxx -Password xxxx
    Get-VMHost |Sort Name |Get-View |
    Select Name,
    @{N=“Type“;E={$_.Hardware.SystemInfo.Vendor+ “ “ + $_.Hardware.SystemInfo.Model}},
    @{N=“Serial Number“;E={$_.Hardware.SystemInfo.OtherIdentifyingInfo[0].IdentifierValue+ “ “ }},
    @{N=”Datacenter”;E={Get-datacenter -VMHost $_.Name}},
    @{N=“CPU“;E={“PROC:“ + $_.Hardware.CpuInfo.NumCpuPackages + “ CORES:“ + $_.Hardware.CpuInfo.NumCpuCores + “ MHZ: “ +

    [math]::round($_.Hardware.CpuInfo.Hz / 1000000, 0)}},
    @{N=“MEM“;E={“” + [math]::round($_.Hardware.MemorySize / 1GB, 0) + “ GB“}} | Export-Csv c:\hostinfo.csv

  8. Sathe

    Here is the updated code to get the serial Number of the ESXI Host.

    Connect-VIServer vcentername -User xxxxx -Password xxxxxx
    Get-VMHost |Sort Name |Get-View |
    Select Name,
    @{N=“Type“;E={$_.Hardware.SystemInfo.Vendor+ “ “ + $_.Hardware.SystemInfo.Model}},
    @{N=“Serial Number“;E={$_.Hardware.SystemInfo.OtherIdentifyingInfo[0].IdentifierValue+ “ “ }},
    @{N=“CPU“;E={“PROC:“ + $_.Hardware.CpuInfo.NumCpuPackages + “ CORES:“ + $_.Hardware.CpuInfo.NumCpuCores + “ MHZ: “ + [math]::round($_.Hardware.CpuInfo.Hz / 1000000, 0)}},
    @{N=“MEM“;E={“” + [math]::round($_.Hardware.MemorySize / 1GB, 0) + “ GB“}} | Export-Csv c:\hostinfo.csv

  9. Richard Johnson

    Hi, im using the below but get a blank entry for Datacenter.

    Get-VMHost | Get-View | Select Name,
    @{N=”Datacenter”;E={Get-datacenter -VMHost $_}}

    If i do Get-datacenter -VMHost “host name” then i get the correct output. Why?

  10. HeM

    how can I get virtual machine rhard disk withing a particular cluster ..

    regards
    HeM

  11. chad king

    Hey man,
    Saved again by your amazing scripts. You should really add this to the vmware community powerpack. Hell I would would If I knew how. I really need this information for “socket” licensing stuff. lol.

  12. Daryl

    Anyone figure out how to get the host’s serial number? I can see it in VC under the hosts’ ‘Hardware Status’ ‘System summary’ information.

  13. Virtu-Al

    Unfortunatly the serial number is a bit of a pain as different vendors put it in different places, have you checked Carters CIM script ?

  14. Virtu-Al

    @Mark M
    Not in front of my VI at the moment but try this:

    Get-VMHost |Sort Name |Get-View |
    Select @{N=“DataCenter“;E={Get-VMHost $_ | Get-Datacenter}}, Name,
    @{N=“Type“;E={$_.Hardware.SystemInfo.Vendor+ “ “ + $_.Hardware.SystemInfo.Model}},
    @{N=“CPU“;E={“PROC:“ + $_.Hardware.CpuInfo.NumCpuPackages + “ CORES:“ + $_.Hardware.CpuInfo.NumCpuCores + “ MHZ: “ + [math]::round($_.Hardware.CpuInfo.Hz / 1000000, 0)}},
    @{N=“MEM“;E={“” + [math]::round($_.Hardware.MemorySize / 1GB, 0) + “ GB“}} | Export-Csv c:\hostinfo.csv

  15. Pingback: Pycc 3ona - Новости » Blog Archive » Virtu-Al » PowerCLI: Host Hardware One-Liner

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.