I'm using this script to get the host serial number, U also need the manufacturer, but couldn't figure out the correct parameter.
Get-Vmhost | Get-View | Sort-object Name | select Name, @{N='Product';E={$_.Config.Product.FullName}}, @{N='Build';E={$_.Config.Product.Build}}, @{Name="Serial Number"; Expression={($_.Hardware.SystemInfo.OtherIdentifyingInfo | where {$_.IdentifierType.Key -eq "ServiceTag"}).IdentifierValue}}
You have to use the pipeline variable ($_).
Like this
Sort-object Name |
select Name,
@{N = 'Product'; E = { $_.Config.Product.FullName } },
@{N = 'Build'; E = { $_.Config.Product.Build } },
@{Name = "Serial Number"; Expression = { ($_.Hardware.SystemInfo.OtherIdentifyingInfo | where { $_.IdentifierType.Key -eq "ServiceTag" }).IdentifierValue } },
@{N = 'Vendor'; E = { $_.Hardware.SystemInfo.Vendor } },
@{N = 'Model'; E = { $_.Hardware.SystemInfo.Model}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Try like this
Sort-object Name |
select Name,
@{N='Product';E={$_.Config.Product.FullName}},
@{N='Build';E={$_.Config.Product.Build}},
@{Name="Serial Number"; Expression={($_.Hardware.SystemInfo.OtherIdentifyingInfo | where {$_.IdentifierType.Key -eq "ServiceTag"}).IdentifierValue}},
@{N='Vendor';E={$_.Hardware.SystemInfo.Vendor}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
And the model please. Is it like this?
@{N="Model"; E={hardware.systeminfo.model}}
?
You have to use the pipeline variable ($_).
Like this
Sort-object Name |
select Name,
@{N = 'Product'; E = { $_.Config.Product.FullName } },
@{N = 'Build'; E = { $_.Config.Product.Build } },
@{Name = "Serial Number"; Expression = { ($_.Hardware.SystemInfo.OtherIdentifyingInfo | where { $_.IdentifierType.Key -eq "ServiceTag" }).IdentifierValue } },
@{N = 'Vendor'; E = { $_.Hardware.SystemInfo.Vendor } },
@{N = 'Model'; E = { $_.Hardware.SystemInfo.Model}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
"Vendor" works, but "model" isn't retreiving anything, actually it's the same syntax I used for "model".
it worked, my bad, I forgot to put the suffix "$_."
Thanks for saving my day,
You also can do this:
get-vmhost | get-vmhosthardware | select vmhost,Manufacturer,Model,SerialNumber