How to locate serial number for my hardware ESXi 4 ?
$h = Get-VMHost <escihostnamehere> | Get-View
$h.Hardware.SystemInfo
I get unknown
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
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>
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
use the below command for the same
esxcfg-info | grep "Serial Number"
thanks
Tanav
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.
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
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
Plink.exe > ESXi ? it has no service console right ?
Can we use CIM somehow from PowerCLI ?
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
Lockdown mode is disabled.
Under Host View > Configuration > Security Profile > Services > Vmware vCenter Agent and NTP deamon is running.
But i still get error using plink.exe..
Connecting to <hostIP> port 22
Failed to connect to <hostIP>: Network error: Connection refused
Network error: Connection refused
Any clues ?
We enabled indeed ssh on our ESXi servers.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
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 ?
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]
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
Powershell V2 CTP3 -- unsupported technology. Not for production use
Not sure what to do next to get serial number.
Cannot SSH on ESXi - unsupported
Cannot use PoshV2 - unsupported
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
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]