Expert
Expert

How to get the serial number of the esx host?

How to get the serial number of the esx host e.g HP DL 585, which is displayed in the hard health status tab.

14 Replies
Leadership
Leadership

Did you already look at

____________

Blog: LucD notes

Twitter: lucd22


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

Expert
Expert

Yes I read this articel, but for HP Servers and esxi 4 is no way to get the serial number per powershell.

If I read it correct, than only over it is possible to get the serial number.

0 Kudos
Leadership
Leadership

If it concerns an ESX server did you try ?

esxcfg-info | grep "Serial N"

If that returns the serial number you could try to use plink.exe.

But for some HW/HW types it seems that it's impossible to get the serial number via PowerShell.

____________

Blog: LucD notes

Twitter: lucd22


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

Expert
Expert

Today I tried it for Dell server and powershell works. For HP not.

Could it be that it has to do, that HP alwaws brands the hardware this their hardware.

So did anyone get the serial number from IBM, Fujitsu and Cisco servers with powershell?

0 Kudos
Contributor
Contributor

Why not try this script after connect-viserver ?

$esxlist = get-vmhost

foreach($Esx in $esxlist){

$esxcli=Get-EsxCli -VMHost $Esx

write-host $Esx.Name $esxcli.hardware.platform.get().SerialNumber

}

Regards

Kevin Smith

0 Kudos
Contributor
Contributor


The script suggested by VKEV worked in my environment.  Does the following command and argument apply to all host in a cluster?

foreach($Esx in $esxlist

Thank you

bobby.batts@lipocience.com

0 Kudos
Leadership
Leadership

No, in $esxlist you will have all the ESXi in your vCenter.

If you only want the ESXi for a specific cluster, change that first line into

$esxlist = Get-Cluster -Name MyCluster | Get-VMHost


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

0 Kudos
Contributor
Contributor

Okay, thanks. While I have attention, what is the best text to purchase for a beginner in PowerCLI. Your input would be greatly appreciated.

Bobby Batts

Liposcience

919-709-9118

0 Kudos
Leadership
Leadership

Well there are 2 parts in that, first you will need some intro to PowerShell.

There are some good, and free, sources available for that.

Secondly there is the PowerCLI part.

Josh's has a good list of resources, see his Resources for Getting Started with #PowerCLI Automation


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

0 Kudos
Contributor
Contributor

Glad it worked,

The main issues with reliably retrieving the serial number are:

- vCenter only caches the serial number in the inventory database ( hence sometimes it is not returned )

- Accessing the host serial number via CIM can return the chassis serial number as well...

If it were held in the vCenter DB things would be easier...

0 Kudos
Enthusiast
Enthusiast

So I know this is an extremely old thread, but the script provided by KevD is great, except I need to export to CSV, every combination of export-csv doesn't seem to work for me, any help please?

thx

0 Kudos
Leadership
Leadership

Try like this

Get-VMHost | Select Name,

    @{N='Serial';E={(Get-EsxCli -VMHost $_).hardware.platform.get().SerialNumber}} |

Export-Csv serial.csv -NoTypeInformation -UseCulture


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

Enthusiast
Enthusiast

LucD.  Thank you for the extremely quick and correct response.

Thanks,

GB

0 Kudos
Contributor
Contributor

Thanks Luc, I've been reading a lot of different ways of extracting the serial number but this is the syntax I've been looking for.  Thanks very much!

----------------------- "Crippling Microsoft is the geek equivalent of taking down the Death Star"
0 Kudos