Get computer serial number and other info with PowerShell


To get the serial number from a computer run the following PowerShell command:

gwmi win32_bios | fl SerialNumber

To get more information e.g. bios version and manufacturer just run:

gwmi win32_bios


Comments (11)

  1. Anonymous says:

    You can use Invoke-Command.
    E.g. Invoke-Command -ComputerName DC1 {Get-WmiObject win32_bios}

  2. Anonymous says:

    Helpful indeed

  3. Anonymous says:

    georg do you have some kind of inventory system like SCCM? Then you can query it for the serial number.

  4. Anonymous says:

    If you want to store it as a variable just do something like:
    $SN = gwmi win32_bios | Select-Object SerialNumber
    or if you just want to store the value:
    $SN = gwmi win32_bios | Select –ExpandProperty SerialNumber

  5. arockia says:

    very helpful

  6. coleman984 says:

    How do you do this for a computer over the network?

  7. Georg says:

    how can i find a Serialnummer in my domain.
    I have onla the seriennummer (hardware)
    thx

  8. Spencer says:

    If I wanted to then pass this to a variable in a script how would i go about that?

  9. Alexavius says:

    $currenttime = get-date
    $Results = @()

    Function Get-SerialNumber{

    Param
    (
    [Parameter(Mandatory=$true)]
    $Computer
    )

    Try{
    $erroractionpreference="SilentlyContinue"
    $SerialNumber = Invoke-Command -ComputerName $computer {gwmi win32_bios | Select –ExpandProperty SerialNumber}
    }
    Catch{
    $SerialNumber = "Not found"
    }

    $CustomObject = new-object PSobject
    $CustomObject | add-member -membertype noteproperty -name "Computer_Name" -value $Computer
    $CustomObject | add-member -membertype noteproperty -name "SerialNumber" -value $null

    IF($SerialNumber){

    $CustomObject.SerialNumber = $SerialNumber

    }

    $CustomObject
    }

    write-host "Starting SerialNumber Lookup at $currenttime"

    Foreach ($computer in $computers){
    $erroractionpreference="SilentlyContinue"
    $onlinestatus = test-connection $computer -Count 1 -quiet
    if ($onlinestatus -eq $true)
    {
    write-host "Starting SerialNumbers Lookup on $computer"

    Try{$Results += (Get-SerialNumber -Computer $Computer)}
    Catch{Write-Host "An error occured reading data from $computer; skipping"}
    }
    else
    {
    write-host "$computer is Offline" -foregroundColor Red
    }
    $Results | Export-CSV -Path $CSVOutputLocation -NoTypeInformation
    }

  10. blake says:

    You can also use wmic:
    wmic bios get serialnumber