jFishner
Contributor
Contributor

Serial number ?

How to locate serial number for my hardware ESXi 4 ?

$h = Get-VMHost <escihostnamehere> | Get-View

$h.Hardware.SystemInfo

I get unknown

31 Replies
LucD
Leadership
Leadership

Did you have a look at and ?

Depending on the HW you're using this might or might not be exposed via the SDK.


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

0 Kudos
harkamal
Expert
Expert

Hi LucD

Isee this post http://communities.vmware.com/docs/DOC-7170 and his script

Author is connecting to root\cimv2 namespace which is same as we used to query wmi on windows boxes. but I am unable to connect to wmi namespace on esxi box using the following code..sorry first time querying esxi using wmi

PS C:\HK-WorkArea\VmWare> Get-WmiObject cim_computersystem -ComputerName https://<myhostname.fqdn>

Get-WmiObject : Invalid parameter

At line:1 char:14

+ Get-WmiObject <<<< cim_computersystem -ComputerName https://<myhostname.fqdn>

0 Kudos
LucD
Leadership
Leadership

I suspect you have to enable the CIM service first.

Perhaps have a look at Joep's article Enabling CIM on ESXi.


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

0 Kudos
harkamal
Expert
Expert

I see CIM is operational on ESXi box.. but still this error using CIM.....is this the right way of doing this ? or i have to elarn another CIM SDK ?

0 Kudos
Tanav
Enthusiast
Enthusiast

use the below command for the same

esxcfg-info | grep "Serial Number"

thanks

Tanav

harkamal
Expert
Expert

Its ESXi with no console os.

I see vSphereCLI, but no corresponding scripts are there to esxcfg-info.

Getting serial number has become such a challenge.

0 Kudos
jFishner
Contributor
Contributor

We can only use PowerCLI for all VI purposes...i see CIM SDK to be complicated stuff..can someone guide from powershell perspective please..really important to get serial number

thanks a lot

0 Kudos
LucD
Leadership
Leadership

A solution that uses the plink.exe command from the PuTTY suite.

$User = <ESX-account>
$Pswd = <ESX-password>
$hostName = <ESX-hostname>
$plink = "<PuTTY-directory>\plink.exe"

$plinkoptions = " -v -batch -pw $Pswd"
$cmd1 = 'esxcfg-info'

$remoteCommand = '"' + $cmd1 + '"'
$command = $plink + " " + $plinkoptions + " " + $User + "@" + $hostName + " " + $remoteCommand

$msg = Invoke-Expression -command $command

$mask = [regex]"Serial Number\.*(\w+)"
$result = $mask.Matches($msg)
$serial = $result[0].Groups[1].Value

Write-Host "Host:" $hostName
Write-Host "Serial Number:" $serial


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

0 Kudos
harkamal
Expert
Expert

Plink.exe &gt; ESXi ? it has no service console right ?

Can we use CIM somehow from PowerCLI ?

0 Kudos
LucD
Leadership
Leadership

You don't logon to the COS, which is not there, but directly to the hypervisor (tech support mode).

When the ESXi is locked down this won't work of course.


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

0 Kudos
harkamal
Expert
Expert

Lockdown mode is disabled.

Under Host View &gt; Configuration &gt; Security Profile &gt; Services &gt; Vmware vCenter Agent and NTP deamon is running.

But i still get error using plink.exe..

Connecting to &lt;hostIP&gt; port 22

Failed to connect to &lt;hostIP&gt;: Network error: Connection refused

Network error: Connection refused

Any clues ?

0 Kudos
harkamal
Expert
Expert

Hi LucD,

Are you suggesting to enable ssh as mentioned in this article...that a hack..cant do in production environment

0 Kudos
LucD
Leadership
Leadership

We enabled indeed ssh on our ESXi servers.


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

0 Kudos
harkamal
Expert
Expert

Console says it is unsupported unless assisted by a vmware support professional.

Cannot justify to production guys. So much pain for a serial number .. LOL

Can you point me to CIM & PowerCLI marriage ?

0 Kudos
admin
Immortal
Immortal

See Monitoring ESX Hardware with PowerShell.

You should know however that in vSphere there is a bug which prevents generating CIM tokens. This script uses these to re-use the web services connection and not require a second login. Until this bug is fixed you will have to supply your own password for CIM against vSphere.

=====

Carter Shanklin

Read the PowerCLI Blog
[Follow me on Twitter|http://twitter.com/cshanklin]

0 Kudos
halr9000
Commander
Commander

c_shanklin posted about CIM & PowerShell a while back: http://blogs.vmware.com/vipowershell/2009/03/monitoring-esx-hardware-with-powershell.html




[vExpert|http://www.vmware.com/communities/vexpert/], PowerShell MVP, VI Toolkit forum moderator

Author of the book: Managing VMware Infrastructure with PowerShell

Co-Host, PowerScripting Podcast (http://powerscripting.net)

Need general, non-VMware-related PowerShell Help? Try the forums at PowerShellCommunity.org

My signature used to be pretty, but then the forum software broked it. vExpert. Microsoft MVP (Windows PowerShell). Author, Podcaster, Speaker. I'm @halr9000
0 Kudos
harkamal
Expert
Expert

Powershell V2 CTP3 -- unsupported technology. Not for production use Smiley Sad

Not sure what to do next to get serial number.

Cannot SSH on ESXi - unsupported

Cannot use PoshV2 - unsupported

0 Kudos
halr9000
Commander
Commander

Not true, it is out today if you are running Windows7 or 2008 R2. It'll be out for Vista and 2008 at GA (general availability) of W7 which is Oct 23rd. V2 for XP and 2003 will come 30-90 days after if I recall correctly.

[vExpert|http://www.vmware.com/communities/vexpert/], PowerShell MVP, VI Toolkit forum moderator

Author of the book: Managing VMware Infrastructure with PowerShell

Co-Host, PowerScripting Podcast (http://powerscripting.net)

Need general, non-VMware-related PowerShell Help? Try the forums at PowerShellCommunity.org

My signature used to be pretty, but then the forum software broked it. vExpert. Microsoft MVP (Windows PowerShell). Author, Podcaster, Speaker. I'm @halr9000
0 Kudos
admin
Immortal
Immortal

I'm not sure where the CIM thing is coming from, isn't the data you need available?

If I SSH into my ESX system I get:

[root@pa-sdk-d83 ~]# esxcfg-info | grep "Serial N"
      |----Serial Number............................................1T9M6G1

If I run

[vSphere PowerCLI] C:\> $hView = get-vmhost | get-view
[vSphere PowerCLI] C:\> $hView.Hardware.SystemInfo.OtherIdentifyingInfo | select IdentifierValue, { $_.IdentifierType.Key }

IdentifierValue                          $_.IdentifierType.Key
---------------                         -----------------------
 unknown                                AssetTag
1T9M6G1                                 ServiceTag

Is the problem that some hardware doesn't populate this information? Can someone try this code and see if it gives enough information? I had to post the code on another site since the forum software here is too stupid to deal with square brackets, apologies for that.

Just run Get-VMHost | Get-SerialNumber

=====

Carter Shanklin

Read the PowerCLI Blog
[Follow me on Twitter|http://twitter.com/cshanklin]

0 Kudos