VMware Cloud Community
meistermn
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
LucD
Leadership
Leadership

Did you already look at

____________

Blog: LucD notes

Twitter: lucd22


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

meistermn
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.

Reply
0 Kudos
LucD
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

meistermn
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?

Reply
0 Kudos
vkev
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

brbatts
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

Reply
0 Kudos
LucD
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

Reply
0 Kudos
brbatts
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

Reply
0 Kudos
LucD
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

Reply
0 Kudos
vkev
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...

Reply
0 Kudos
gjbrown
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

Reply
0 Kudos
LucD
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

gjbrown
Enthusiast
Enthusiast

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

Thanks,

GB

Reply
0 Kudos
merovingianA51
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!

-TabarnacST
Reply
0 Kudos