Collect Service Tags/Serial Numbers using PowerCLI

Collect Service Tags/Serial Numbers using PowerCLI

Here is a useful PowerCLI script to collect Service Tags and Serial Numbers of the servers/blades. If you are maintaining an Inventory or gathering some information about the current hardware in your Datacenter this might be very useful to gather these information.

Run this script in your vCenter server and you will get the similar output as below. I have highlighted the serial numbers of the blades and servers in RED. In UCS you have the Chassis serial number and the blade serial number (right side) in the output.

Serial Numbers using PowerCLI : Output

Create a script after copying the below code and save as a .ps1 file. Execute the script and you get the service tags of your servers. You may need to add your vCenter server IP or FQDN, username and password to this script. Also if you wish to export this to a .csv file add the Exprt-csv pipeline to export to a csv file.

Connect-VIServer -Server  <IP_or_FQDN> -User "DOMAIN\USERNAME" -Password "password"
$hostname = Get-View -ViewType HostSystem -property name,Hardware.SystemInfo
foreach ($hname in $hostname)
$hn = $
$Man = $hname.Hardware.SystemInfo.Vendor
$Mod = $hname.Hardware.SystemInfo.Model
$serviceTag = $($hname.Hardware.SystemInfo.OtherIdentifyingInfo | where {$_.IdentifierType.Key -eq “ServiceTag” }).IdentifierValue

$hname | Add-Member -MemberType NoteProperty -Name VMHost -Value $hn
$hname | Add-Member -MemberType NoteProperty -Name OEM -Value $Man
$hname | Add-Member -MemberType NoteProperty -Name Model -Value $Mod
$hname | Add-Member -MemberType NoteProperty -Name ServiceTag -Value $serviceTag

$hostname | select VMHost, OEM, Model, ServiceTag

Download the script.

Click to rate this post!
[Total: 5 Average: 4.2]

Leave a Reply

Your email address will not be published. Required fields are marked *