VMware Cloud Community
RonPSSC
Enthusiast
Enthusiast
Jump to solution

PowerCLI Help Needed With Retrieving ESXi Host Asset Tag Info

Hoping someone, anyone, will be able to help me figure out what I may be doing wrong and how to use PowerCLI to retrieve valid ESXi host Asset Tag information that is displayed on the Hardware Status Tab in vCenter. I have absolutely no issues retrieving Host Serial Numbers (sometimes referred to as Service Tags), Manufacture, Model, Part, Build Numbers, etc, but can't seem to be able to poll current Asset Tag Numbers.

None of the following attributes or property values identified below returned the information required and which currently exists (See image below):

Hardware.SystemInfo.OtherIdentifyingInfo[0].IdentifierValue

Hardware.SystemInfo.OtherIdentifyingInfo[1].IdentifierValue

Hardware.SystemInfo.OtherIdentifyingInfo[2].IdentifierValue

Hardware.SystemInfo.OtherIdentifyingInfo | where {$_.IdentifierType.Key -eq "assettag"}).identifierValue

vCenter Server Hardware Status Tab - Asset Tag Info.png

This is the script I'm currently running. I'm using PowerCLI Version 5.1:

$VIServer = "Enter vCenter Server Name"


# Adding PowerCLI core snapin
if (!(get-pssnapin -name VMware.VimAutomation.Core -erroraction silentlycontinue)) {
add-pssnapin VMware.VimAutomation.Core
}

Connect-VIServer $VIServer

$HostReport = @()

$VMH = Get-VMHost | Get-View |%{    

     $Report = "" | select Hostname, Version, Build, Manufacture, Model, Serial, Asset Tag

     $Report.Hostname = $_.Name

     $Report.version =$_.Config.Product.Version

     $Report.Build =$_.Config.Product.Build

     $Report.manufacture =$_.Hardware.SystemInfo.Vendor

     $Report.Model =$_.Hardware.SystemInfo.Model

     $Report.Serial =$_.Hardware.SystemInfo.OtherIdentifyingInfo[0].IdentifierValue

     $Report.Asset Tag =????????????????????????

     $HostReport += $Report
     
}

$HostReport | Export-Csv ".\HostReport.csv" –NoTypeInformation

Disconnect-VIServer -Confirm:$false

Thx. Ron

1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Afaik this has nothing to do with PowerCLI, it's the way vCenter gets this information, and how and where some HW vendors make this information available.

With the CIM interface you can dump all the available information, and then find out where exactly the tag is hiding.

See what this returns

import-module CimCmdlets
$esxiHostname = "MyESXiServer"
$HostUsername = "root"
$CIOpt = New-CimSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck -Encoding Utf8 -UseSsl
$Session = New-CimSession -Authentication Basic -Credential $HostUsername -ComputerName $esxiHostname -port 443 -SessionOption $CIOpt
Get-CimInstance -CimSession $Session -ClassName CIM_Chassis

You will be prompted for the ESXi root password.

On some of our older IBM HW I get the following where the asset tag is expected.

assettag.png

But the information is there, just in another property.

As we already mentioned during our VMworld session, explore the CIM API.

There is a wealth of information in there


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

View solution in original post

0 Kudos
13 Replies
rtunisi
Contributor
Contributor
Jump to solution

The issue i found is that 'OtherIdentifyingInfo' is a collection of objects (i suppose)... so you need to use -ExpandProperty on a select statement, like this:

$helper = $_.hardware.systeminfo | Select -ExpandProperty OtherIdentifyingInfo

$helper variable will get all the objects associated which OtherIdentifyingInfo, so you need a foreach to find the attribute needed. I think you should find what you need on 'IdentifierValue' and 'IdentifierType.Label' Attributes

see if this helps

RonPSSC
Enthusiast
Enthusiast
Jump to solution

Thanks for responding..!! Very helpful answer but unfortunately the output did not reveal anything further than what had been made availaible using the specific Identifier Values, i.e., Hardware.SystemInfo.OtherIdentifyingInfo[0], [1], or [2]...  😞

 

I do however want to thank you for providing me with enough info to allow me to list all the Properties associated with a given Object!! I'm really somewhat of a novice when it comes to PowerCLI and have so far gotten by using scripts developed by others. I honestly did not know how to traverse vim assemblies to expand upon their individual Properties. I realize this is probably basic stuff so chalk this up to pure laziness perhaps or just me cutting corners as per usual.  :-o)

Incidentally, another method which allowed me to parse an Object’s relevant Properties was by using this:

 

{$_.hardware.systeminfo.OtherIdentifyingInfo | Select *}

 

Now back to the issue at hand. It looks as though the mystery still persists.  I quickly validated almost all of the objects within Summary, Hardware, Config and Config Manager vim assemblies and still can’t find the information I need using PowerCLI. Why is this?? Particularly since the Asset Tag is a valid field in vCenter with legitimate data??? Is there a limitation as to what PowerCLI can extrapolate?

Thx. Ron

0 Kudos
RonPSSC
Enthusiast
Enthusiast
Jump to solution

Is there anyone out there able to figure this one out??

Thx. Ron

0 Kudos
RonPSSC
Enthusiast
Enthusiast
Jump to solution

Not having much success with this post. Can anyone advise as to what my next options might be, if any, to solving this issue? Can I get formal Support from VMware on matters pertaining to this management framework?

Thx. Ron

0 Kudos
markdjones82
Expert
Expert
Jump to solution

I'm using Dell and I used to be able to get the serial using Powercli on 5.0, but I just recently upgraded to 5.1 U1 and I have noticed the array is blank now

Hardware.SystemInfo.OtherIdentifyingInfo

Not sure why this info is not populating in there.  If we don't get a response I'll hit up  Alan Renouf on twitter as I think he has a pipeline into the powercli devs and maybe he can shed some light on this.

http://www.twitter.com/markdjones82 | http://nutzandbolts.wordpress.com
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Afaik this has nothing to do with PowerCLI, it's the way vCenter gets this information, and how and where some HW vendors make this information available.

With the CIM interface you can dump all the available information, and then find out where exactly the tag is hiding.

See what this returns

import-module CimCmdlets
$esxiHostname = "MyESXiServer"
$HostUsername = "root"
$CIOpt = New-CimSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck -Encoding Utf8 -UseSsl
$Session = New-CimSession -Authentication Basic -Credential $HostUsername -ComputerName $esxiHostname -port 443 -SessionOption $CIOpt
Get-CimInstance -CimSession $Session -ClassName CIM_Chassis

You will be prompted for the ESXi root password.

On some of our older IBM HW I get the following where the asset tag is expected.

assettag.png

But the information is there, just in another property.

As we already mentioned during our VMworld session, explore the CIM API.

There is a wealth of information in there


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

0 Kudos
markdjones82
Expert
Expert
Jump to solution

Ah that makes sense, now if I can just find the time to read up on all that stuff :smileysilly:

Thanks Luc.  I've always wondered is there a good powershell 3.0 cmdlet reference page like we have with Powercli where I can look up all the cmdlets that are part of powershell 3.0?

http://www.twitter.com/markdjones82 | http://nutzandbolts.wordpress.com
0 Kudos
LucD
Leadership
Leadership
Jump to solution

You can find all the core cmdlets here.

And then there are the numerous modules, who most of the time also publish a reference page


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

0 Kudos
markdjones82
Expert
Expert
Jump to solution

Luc,

  Would there be anyway to pass the password to the basic credential?  I didnt' see a switch for password.  I am trying to get around the password prompt if possible

http://www.twitter.com/markdjones82 | http://nutzandbolts.wordpress.com
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Yes, you can create a PSCredential object that you can pass on the Credential parameter

$username = "account"
$pswd = "password"
$pswdSecure = ConvertTo-SecureString -String $pswd -AsPlainText -Force
$cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $username,$pswdSecure


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

0 Kudos
RonPSSC
Enthusiast
Enthusiast
Jump to solution

Hi Luc;


Thank you so much for responding. This is excellent!! Once I upgraded my PowerShell foundation to v 3.0 on my Windows 7 workstation I was able to gather the info I was looking for. Sure enough the data was embedded at the CIM layer. Smiley Happy

I was wondering if there was a way to automate populating the "$esxiHostname" variable in the script by perhaps piping in ESXi Server Names listed within and from each vCenter or maybe by reading a manual list??  Naturally, we would prefer the automated method. Thx in advance.  Below is an sample script I was able to develop using your source info:

import-module CimCmdlets


$HostReport = @()

$esxiHostname = "MyESXiHost1", "MyESXiHost2"
$HostUsername = "root"
$CIOpt = New-CimSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck -Encoding Utf8 -UseSsl
$Session = New-CimSession -Authentication Basic -Credential $HostUsername -ComputerName $esxiHostname -port 443 -SessionOption $CIOpt


Get-CimInstance -CimSession $Session -ClassName CIM_Chassis | % {

    $Report = ""| Select HostName, Model, SerialNumber, AssetTagInfo 

    $Report.HostName = $_.PSComputerName
    $Report.Model = $_.Model
    $Report.SerialNumber = $_.SerialNumber

    $Report.AssetTagInfo = $_.OtherIdentifyingInfo

    $HostReport += $Report
       
  }
  
   
$HostReport | Sort-object -Property HostName | Export-Csv ".\HostHardwareReport.csv" –NoTypeInformation


Much appreciated. Ron

0 Kudos
LucD
Leadership
Leadership
Jump to solution

You mean like this ?

import-module CimCmdlets

$HostUsername = "root"

$HostReport = @()

$CIOpt = New-CimSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck -Encoding Utf8 -UseSsl

Get-VMHost | %{
   
$Session = New-CimSession -Authentication Basic -Credential $HostUsername -ComputerName $_.Name -port 443 -SessionOption $CIOpt


   
Get-CimInstance -CimSession $Session -ClassName CIM_Chassis | % {

       
$Report = ""| Select HostName, Model, SerialNumber, AssetTagInfo

       
$Report.HostName = $_.PSComputerName
       
$Report.Model = $_.Model
       
$Report.SerialNumber = $_.SerialNumber

       
$Report.AssetTagInfo = $_.OtherIdentifyingInfo

       
$HostReport += $Report

    }
}

$HostReport | Sort-object -Property HostName | Export-Csv ".\HostHardwareReport.csv" NoTypeInformation


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

RonPSSC
Enthusiast
Enthusiast
Jump to solution

Wow, that was pretty easy.. :smileylaugh: As I indicated above, I'm somewhat of a novice.. :smileyblush:

Thank you kindly, Luc..!!

0 Kudos