retrieve an IBM servers serial number with Powershell.

We’ve all been there, we’ve a hardware call to log with a vendor, time is of the essence but yet, when they ask… we’ve forgotten to take down the serial number.

Here’s a few quick powershell one liners for getting the serial number using WMI.

I’ve tested this on IBM, and dell hardware but theres no reason it wont work on other systems.

Getting the local serial number:

get-wmiobject win32_bios | select-object serialnumber

Getting a remote serial number:

get-wmiobject win32_bios -computername remotecomputername | select-object serialnumber

I have a full self contained function after the jump should you wish to use it.

 
function get-serialnumber {
<#
    .Synopsis
        Retrieves the machines serial number from the bios.
    .Description
        Queries the local, or optionally remote machines serial number and returns it.
    .Parameter computername
        (Optional) the computername you wish to query.
    .Example
        C:PS> get-serialnumber

        serialnumber
        ------------
        8DZ5X2J

        Description
        -----------
        Retrieves the serial number of the local machine and returns it.

    .Example
        C:PS> get-serialnumber -computername xps

        serialnumber
        ------------
        8DZ5X2J

        Description
        -----------
        Retrieves the serial number on the remote machine and returns it.

    .Notes
        AUTHOR:     Andrew Morgan
        Notes: this is confirmed to work on IBM and Dell Hardware, for other vendors this should work but is untested.

    #>

    param(
    [Parameter(HelpMessage="Server Name, Default is Localhost")]
    [string]$computername=$env:computername)

    Return $serial=get-wmiobject win32_bios -computername $computername |
     select-object serialnumber}

2 Comments About “retrieve an IBM servers serial number with Powershell.

Leave a Reply