Im trying to pull a vmhosts product ID & Serial number, i have been able to get the serial number using the following:
$esxcli = Get-EsxCli -VMhost HostName -V2
$esxcli.hardware.platform.get.Invoke() | Select @{N='VMHost';E={$esxcli.VMHost.Name}},SerialNumber
However i cant seem to find the option for Product ID using get-esxcli... if i run the below command i get the product ID among other entries:
(get-vmhost HostName | get-view).hardware.systeminfo.OtherIdentifyingInfo
Is it possible to separate out Product ID from the list so it can be included with the serial number? They all appear to have the same identifier type
These entries normally have a Key, which you can use to retrieve the desired entry.
First list the available keys and values.
$esx.ExtensionData.Hardware.SystemInfo.OtherIdentifyingInfo |
ForEach-Object -Process {
[PSCustomObject]@{
Key = $_.IdentifierType.Key
Value = $_.IdentifierValue
}
}
Then you can use the Key to retrieve the desired entry.
$tgtKey = '<Key>'
$esx.ExtensionData.Hardware.SystemInfo.OtherIdentifyingInfo |
where{$_.IdentifierType.Key -eq $tgtKey} |
Select -ExpandProperty IdentifierValue
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Not too sure what you mean by Product ID.
Is it the HW model?
@{N='Model';E={$_.ExtensionData.Hardware.SystemInfo.Model}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
So i managed to get the product name e.g. "ProLiant DL380p Gen8" but i want the ID e.g "Product ID: 642121-421"
With the get-view command i get the following list:
IdentifierValue IdentifierType
--------------- --------------
0**** VMware.Vim.ElementDescription
CZ******** VMware.Vim.ElementDescription
CZ******** VMware.Vim.ElementDescription
CZ******** VMware.Vim.ElementDescription
PSF: VMware.Vim.ElementDescription
Product ID: 642121-421 VMware.Vim.ElementDescription
The ID would be more useful to support when logging support tickets etc
These entries normally have a Key, which you can use to retrieve the desired entry.
First list the available keys and values.
$esx.ExtensionData.Hardware.SystemInfo.OtherIdentifyingInfo |
ForEach-Object -Process {
[PSCustomObject]@{
Key = $_.IdentifierType.Key
Value = $_.IdentifierValue
}
}
Then you can use the Key to retrieve the desired entry.
$tgtKey = '<Key>'
$esx.ExtensionData.Hardware.SystemInfo.OtherIdentifyingInfo |
where{$_.IdentifierType.Key -eq $tgtKey} |
Select -ExpandProperty IdentifierValue
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Annoyingly there are 2 keys with the same name "OemSpecificString" but that first command to find the key names will be massively useful in future, thanks for that
If the Product ID has a specific format, you could use a -match with a RegEx to find the correct entry.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I ended up using:
$esx.ExtensionData.Hardware.SystemInfo.OtherIdentifyingInfo |
where{$_.IdentifierType.Key -eq $tgtKey -and $_.IdentifierValue -like "Product*"} |
Select -ExpandProperty IdentifierValue
Thanks again