Hardware

PowerShell for Serial Number: Get Your Computer's Serial Number

To get the computer's serial number with PowerShell, run (Get-CimInstance -ClassName Win32_BIOS).SerialNumber. It prints the serial number that the manufacturer stored in the firmware, and it works the same on a laptop, a desktop and a virtual machine.

The command needs no administrator window on a typical setup, and it only reads data. It changes nothing on the computer.

The one-line command

(Get-CimInstance -ClassName Win32_BIOS).SerialNumber

Example output (the number below is made up):

PF3XK7QZ

If you also want the manufacturer and BIOS version next to it, select several properties instead of one:

Get-CimInstance -ClassName Win32_BIOS | Select-Object Manufacturer, SMBIOSBIOSVersion, SerialNumber

Example output:

Manufacturer SMBIOSBIOSVersion SerialNumber
------------ ----------------- ------------
Example Inc. 1.14.0            PF3XK7QZ

What the command actually asks Windows

Get-CimInstance reads instances of a WMI class. According to Microsoft's documentation, with no computer name given it works against the local Windows Management Instrumentation (WMI) service. -ClassName Win32_BIOS picks the class that describes the BIOS installed on the computer, and its SerialNumber property is documented as the "assigned serial number of the software element". The surrounding parentheses make PowerShell run the command first, and the .SerialNumber part then pulls that single property out of the result so you get plain text instead of a table.

You can type the class name in any letter case. Tab completion also works on it, because PowerShell reads the class list from the local WMI service.

How to run it step by step

  1. Right-click the Start button and choose Terminal (Windows 11) or Windows PowerShell (Windows 10). You can also press Win+R, type powershell and press Enter.
  2. Paste the command and press Enter.
  3. Read the value on the line below. Select it and press Enter, or right-click, to copy it from the console window.

If PowerShell refuses to run a saved .ps1 script that contains this command, that is the execution policy, not a problem with the command. Typing a command directly at the prompt, as above, is not affected. For scripts, see how to enable running scripts in PowerShell.

Other serial numbers you can read

A computer has more than one serial number. Which one a support form wants depends on what you are registering, so it helps to know where each comes from.

WhatCommandWhere the value comes from
BIOS serial number(Get-CimInstance Win32_BIOS).SerialNumberThe Win32_BIOS class, serial number of the BIOS element
Chassis (case) serial number(Get-CimInstance Win32_SystemEnclosure).SerialNumberThe Serial Number member of the SMBIOS System Enclosure or Chassis structure
Disk serial numbersGet-CimInstance Win32_DiskDrive | Select-Object Model, SerialNumberNumber allocated by the drive manufacturer to identify the physical media

On most branded laptops and prebuilt desktops the BIOS and chassis values match, and that value is the one printed on the sticker. That is common but not guaranteed by the class definitions, so compare both on your machine if the number matters, for example for a warranty claim.

Serial number of each disk

Get-CimInstance -ClassName Win32_DiskDrive | Select-Object Model, SerialNumber

Example output (made-up values; the format of a disk serial differs by manufacturer):

Model                    SerialNumber
-----                    ------------
Example NVMe SSD 512GB   0123_4567_89AB_CDEF.
Example USB Disk         0000000000000001

Microsoft's documentation for this property gives WD-WM3493798728 as an example of what a disk serial looks like. USB sticks and external drives also appear here while they are plugged in, so the list may contain more rows than the drives inside the case.

Get the serial number of a remote computer

Get-CimInstance -ClassName Win32_BIOS -ComputerName PC01 | Select-Object PSComputerName, SerialNumber

Replace PC01 with the name, fully qualified domain name or IP address of the other computer. The documentation says that when you give -ComputerName, the cmdlet creates a temporary session to that machine over the WsMan protocol. Your account needs permission to query it remotely, and the remote computer has to accept that kind of connection. If the firewall or remote management settings block it, you get an error instead of a number.

To check several computers in one go, pass a list. Microsoft's own example does the same with two server names:

Get-CimInstance -ClassName Win32_BIOS -ComputerName PC01, PC02 | Select-Object PSComputerName, SerialNumber

Microsoft notes that if you run many operations against the same machine, a CIM session gives better performance than repeating -ComputerName. For a one-off serial number lookup the simple form is fine.

Save the serial number to a file

Support portals often ask you to paste the number, and inventory work means collecting it. To write it to a text file in your Documents folder:

(Get-CimInstance -ClassName Win32_BIOS).SerialNumber | Out-File "$HOME\Documents\serial.txt"

To copy it straight to the clipboard instead:

(Get-CimInstance -ClassName Win32_BIOS).SerialNumber | Set-Clipboard

What to do if the output is blank, odd or an error

  • Empty result or a placeholder string. PowerShell shows what the firmware stores. The chassis serial is documented as a manufacturer-allocated number from the SMBIOS structure, so a maker that never filled it in leaves nothing to read. Some custom-built PCs and virtual machines are in this group. Look at the label on the case, the box or the invoice instead.
  • Different values from different classes. Run the BIOS and chassis commands from the table and use the one that matches the sticker or your purchase record.
  • The term "Get-CimInstance" is not recognized. You are probably not in PowerShell on Windows. The cmdlet is Windows only, so it is missing on macOS and Linux builds of PowerShell.
  • Access denied or RPC errors on a remote computer. Your account is not allowed to query it, or the machine blocks remote management. Ask the administrator or run the command locally on that machine.
  • A value that changes after switching boot mode. Microsoft's remarks on Win32_BIOS say some properties can differ for the same machine between legacy BIOS boot and UEFI boot, though the properties taken from SMBIOS structures should stay the same. If a number looks wrong after a firmware change, run the command again and compare it with the label.

Where to find the serial number without PowerShell

The same number is usually printed on a label on the underside of a laptop, or on the back or side of a desktop. If you also need the model name rather than the serial number, the article on finding out what computer model you have covers a PowerShell command and the graphical route. Many manufacturers also have a support utility or a website lookup that reads the same value from the firmware, so check the maker's support page for your model.

Whichever method you choose, copy the number exactly. Serial numbers mix letters and digits, and characters such as the letter O and the digit 0 look alike in some fonts. Pasting the value from the console avoids transcription mistakes that retyping from a sticker can introduce.

Frequently asked questions

Why is the serial number blank or a placeholder?
Windows only reports what the manufacturer wrote into the firmware (SMBIOS). Microsoft describes the chassis serial number as a manufacturer-allocated number taken from the SMBIOS structure. If the maker left the field empty, PowerShell has nothing to show. Check the label on the case or the manufacturer's support tool instead.
Is the BIOS serial number the same as the laptop's serial number?
Usually it is the number support staff ask for, but the class does not guarantee it. Win32_BIOS holds the serial number of the BIOS element, while Win32_SystemEnclosure holds the chassis serial number. Run both and compare, and check the label on the device if they differ.
Does Get-CimInstance work on Mac or Linux?
No. Microsoft's documentation states the cmdlet is only available on the Windows platform, so these commands work in Windows PowerShell and in PowerShell 7 on Windows, but not in PowerShell 7 on macOS or Linux.
Can I get the serial number of another computer on my network?
Yes, with the -ComputerName parameter, for example Get-CimInstance -ClassName Win32_BIOS -ComputerName PC01. You need permission to query that machine remotely. The cmdlet opens a temporary WsMan session to it.

Sources