Get Serial Number of a Remote Computer with PowerShell

The serial number can be useful to identify computer hardware for inventory purpose, which is often written on a small sticker in back side of the device. We can also get this serial number from the BIOS configuration. We can retrieve it using the Windows Management Instrumentation (WMI) class Win32_Bios.

The following command get a serial number of the current computer:

Get-WMIObject Win32_Bios | Select-Object SerialNumber

Get Serial Number of a Remote Computer

You can pass the remote computer name with the paramater –ComputerName and get serial number of remote machine.

Get-WMIObject Win32_Bios -ComputerName 'remote-svr1' | Select-Object SerialNumber

Get Serial Number for a list of Remote Computers using PowerShell

Use the below powershell script to find serial number for multiple remote computers. First create the text file computers.txt which includes one computer name in each line. You will get the machine name and serial number in the csv file SerialNumbers.csv.

Get-Content C:computers.txt  | ForEach-Object{
$ser_number = (Get-WMIObject Win32_Bios -ComputerName $_ ).SerialNumber
if(!$ser_number){
$ser_number ="The server is unavailable"
}
New-Object -TypeName PSObject -Property @{
      ComputerName = $_
      SerialNumber = $ser_number
}} | Select ComputerName,SerialNumber |
Export-Csv C:SerialNumbers.csv -NoTypeInformation -Encoding UTF8

Get Serial Number for a list of Remote Computers from CSV

Use the below powershell script to to find serial number for multiple remote computers from csv file. First create the csv file computers.csv which includes the column ComputerName in the csv file. You will get the ComputerName and SerialNumber list in the csv file SerialNumbers.csv.

Import-Csv C:computers.csv | ForEach-Object{
$ser_number = (Get-WMIObject Win32_Bios -ComputerName $_.ComputerName).SerialNumber
if(!$ser_number){
$ser_number ="The server is unavailable"
}
New-Object -TypeName PSObject -Property @{
      ComputerName = $_.ComputerName
      SerialNumber = $ser_number
}} | Select ComputerName,SerialNumber |
Export-Csv C:SerialNumbers.csv -NoTypeInformation -Encoding UTF8

Advertisement

3 thoughts on “Get Serial Number of a Remote Computer with PowerShell”

    • Hi this error "The RPC server is unavailable" may occurs in following cases

      1. If the targeted machine is down.
      2. If the WMI (Winmgmt) service is down.
      3. If the Remote Procedure Call (RPC) is down.

      Reply

Leave a Comment