VMware Cloud Community
MRoushdy
Hot Shot
Hot Shot
Jump to solution

Get vmhost manufacturer and model

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}}

vEXPERT - VCAP-DCV - Blog: arabitnetwork.com | YouTube: youtube.com/c/MohamedRoushdy
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

You have to use the pipeline variable ($_).

Like this

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 } },

   @{N = 'Vendor'; E = { $_.Hardware.SystemInfo.Vendor } },

   @{N = 'Model'; E = { $_.Hardware.SystemInfo.Model}}


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

View solution in original post

6 Replies
LucD
Leadership
Leadership
Jump to solution

Try like this

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}},

   @{N='Vendor';E={$_.Hardware.SystemInfo.Vendor}}


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

0 Kudos
MRoushdy
Hot Shot
Hot Shot
Jump to solution

And the model please. Is it like this?

@{N="Model"; E={hardware.systeminfo.model}}

?

vEXPERT - VCAP-DCV - Blog: arabitnetwork.com | YouTube: youtube.com/c/MohamedRoushdy
0 Kudos
LucD
Leadership
Leadership
Jump to solution

You have to use the pipeline variable ($_).

Like this

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 } },

   @{N = 'Vendor'; E = { $_.Hardware.SystemInfo.Vendor } },

   @{N = 'Model'; E = { $_.Hardware.SystemInfo.Model}}


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

MRoushdy
Hot Shot
Hot Shot
Jump to solution

"Vendor" works, but "model" isn't retreiving anything, actually it's the same syntax I used for "model".

vEXPERT - VCAP-DCV - Blog: arabitnetwork.com | YouTube: youtube.com/c/MohamedRoushdy
0 Kudos
MRoushdy
Hot Shot
Hot Shot
Jump to solution

it worked, my bad, I forgot to put the suffix "$_."

Thanks for saving my day,

vEXPERT - VCAP-DCV - Blog: arabitnetwork.com | YouTube: youtube.com/c/MohamedRoushdy
0 Kudos
harrytoole
Enthusiast
Enthusiast
Jump to solution

You also can do this:

get-vmhost | get-vmhosthardware | select vmhost,Manufacturer,Model,SerialNumber