Getting the physical serial numbers of Windows servers is something I’m asked to do often, and using Powershell with Get-WMIObject makes that task a relative walk in the park.
An HP article on extracting this information using ESXCLI pointed me in right direction towards using PowerCLI to audit a large number of hosts in one fell swoop.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# Connect to vcenter connect-viserver "VC01"; # Create an empty array $table = @(); # Get all esxi hosts $servers = get-vmhost | sort name; # Loop through each host found foreach ($server in $servers) { # Create an empty row $row = "" | select name, serial; $row.name = $server.name; $esxcli = get-esxcli -vmhost $server.name; $row.serial = $esxcli.hardware.platform.get().serialnumber; # Add row to array $table = $table + $row; } # Export array to CSV $table | export-csv c:\temp\serial.csv |
The resulting output should look something like this:
References:
http://h20564.www2.hp.com/hpsc/doc/public/display?docId=emr_na-c03379226
Thank you!