VMware Cloud Community
Kaz04
Contributor
Contributor
Jump to solution

Esx host service tag

I am trying to run a script to display certain info but cannot get the host service tag to display. I am getting all other info EXCEPT for service tag. Please see the below for what I have so far. Any help would be appreciated.

#make an entry in the array for each one

   foreach ($line in $list){

    $row = "" | select id, vmname , dnsname, model, manufacturer, servicetag, ipaddr, vmhostid, vmguestos, ostype, vmvcpu, vmpowerstate,vmgueststate, vmhostname, vmhostcpu, vmhostcore, vmhostthread, version, build, vc, dc, cluster, date

    $row.id = $line.id

    $row.vmname = $line.name

    $row.dnsname = $line.guest.hostname

    $row.model = $line.vmhost.model

    $row.manufacturer = $line.VMhost.Manufacturer

    $row.servicetag = $line.vmhost.ServiceTag

    $row.ipaddr = $line.guest.ipaddress[0]

    $row.vmhostid = $line.vmhostid

    $row.vmhostname = $line.vmhost

    $row.vmguestos = $line.guest.osfullname

1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try with this line

$row.servicetag = ($line.VMHost.ExtensionData.Hardware.SystemInfo.OtherIdentifyingInfo  | where{$_.IdentifierType.Key -like "ServiceTag"}).IdentifierValue


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

View solution in original post

5 Replies
LucD
Leadership
Leadership
Jump to solution

What do you have in $list?


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

Reply
0 Kudos
Kaz04
Contributor
Contributor
Jump to solution

$list = Get-VM -Server $vc -Location $cluster | sort

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Try with this line

$row.servicetag = ($line.VMHost.ExtensionData.Hardware.SystemInfo.OtherIdentifyingInfo  | where{$_.IdentifierType.Key -like "ServiceTag"}).IdentifierValue


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

Kaz04
Contributor
Contributor
Jump to solution

Works like magic. Thank you so much

Reply
0 Kudos
mfunk
Contributor
Contributor
Jump to solution

Thanks LucD! I've modified this for a one-liner for a quick command line run:

Get-View -ViewType HostSystem | Select Name, @{n="ServiceTag"; e={($_.Hardware.SystemInfo.OtherIdentifyingInfo | ?{$_.IdentifierType.Key -eq "ServiceTag"}).IdentifierValue}} | sort name

Reply
0 Kudos