Home > Administration, PowerShell Scripting, Scripting, Windows Server > retrieve an IBM servers serial number with Powershell.

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}
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: