You can find a device’s serial number directly in PowerShell using the Get-CimInstance cmdlet with the Win32_BIOS class. This method works on almost any modern version of Windows, including Windows 10 and Windows 11, and requires no third-party tools. The command returns a list of hardware details, including the serial number, which you can copy or save to a file.
What You'll Need
- A computer running a version of Windows (10, 11, Server, or Windows 7 with PowerShell 3.0+).
- Administrator privileges are generally not required for this specific task, but some corporate environments may restrict access to certain WMI classes.
Step-by-Step
- Open the Start menu and search for PowerShell. Right-click on the Windows PowerShell or PowerShell app in the results list. Select Run as administrator if you encounter any access denied errors. If the command works without elevation, you can use the standard version.
- In the PowerShell window, type the following command and press Enter:
Get-CimInstance -ClassName Win32_BIOS | Select-Object SerialNumber
- PowerShell will query the Windows Management Instrumentation (WMI) repository for BIOS information. The output will display the serial number of the device. The format of the output is a single line of text, often preceded by a label if you use the Select-Object cmdlet as shown above.
- If you need to see more information than just the serial number—for example, the BIOS version, manufacture date, or name of the BIOS vendor—you can modify the command slightly. You can remove the pipe and Select-Object part to see all available data, or change it to select specific properties. For example, to see the Manufacturer and the Serial Number, use:
Get-CimInstance -ClassName Win32_BIOS | Select-Object Manufacturer, SerialNumber
- To save this information to a text file for later reference, you can pipe the output to the
Out-Filecmdlet. This is useful for creating a hardware inventory list. For example, this command saves the serial number to a file named sn.txt in your current directory:
Get-CimInstance -ClassName Win32_BIOS | Select-Object SerialNumber | Out-File -FilePath .ios-sn.txt
- If you are working with a remote computer and want to get its serial number without physically being at the machine, you can use the
-ComputerNameparameter. You must have administrative access and PowerShell remoting enabled on the target machine. The command would look like this:
Get-CimInstance -ClassName Win32_BIOS -ComputerName ComputerNameOrIP | Select-Object SerialNumber
Common Mistakes
One of the most common mistakes is relying on the Get-WmiObject cmdlet. While this cmdlet still works in some older systems, it has been deprecated in favor of Get-CimInstance. Using Get-WmiObject can sometimes result in slower performance or access errors on modern versions of Windows, so it is best practice to use the CIM cmdlet for new scripts.
Another mistake is not handling the output correctly. The raw output of the command is an object, and the serial number is just one property of that object. If you simply run the command without Select-Object SerialNumber, PowerShell will display a complex table with many columns, including the class type, the time the query was run, and other technical details. This makes the information hard to read and difficult to copy-paste into another document or spreadsheet.
Tips
For a cleaner output, you can use the -ExpandProperty parameter of the Select-Object cmdlet. This will extract just the value of the serial number property and display it as a simple string. The command looks like this:
Get-CimInstance -ClassName Win32_BIOS | Select-Object -ExpandProperty SerialNumber
This is particularly useful when you are scripting the output to a file or using the data in another program that expects a simple text string rather than a complex object.
If you are scripting for a large number of computers, you can loop through a list of computer names. You can create a text file with one computer name per line and read that file using the Get-Content cmdlet. This allows you to generate a serial number report for your entire network efficiently.
Troubleshooting
If the command returns an error, the first thing to check is your network connection. If you are trying to run the command on a remote computer using the -ComputerName parameter, ensure that the computer is turned on and connected to the network. You must also ensure that the target computer has Windows Management Instrumentation (WMI) services enabled and running. On many corporate networks, the firewall may block WMI traffic, which will prevent the command from working.
If you receive an Access Denied error when trying to access a remote computer, verify that you are using the correct credentials. You can specify a username and password with the -Credential parameter. For example:
Get-CimInstance -ClassName Win32_BIOS -ComputerName TargetComputer -Credential (Get-Credential)
This will prompt you for a username and password. Ensure that the account you provide has administrative rights on the target computer.
If you are running the command on a local machine and it fails, check if the BIOS information is actually stored. In rare cases, especially on virtual machines or custom-built PCs with specific firmware, the BIOS object may not contain a serial number property. In these cases, the command may return an empty string or the property may be missing entirely. This is not an error with the command itself, but a limitation of the hardware or firmware configuration.
Frequently Asked Questions
Can I use this command on a Mac or Linux machine?
No, the Win32_BIOS class is specific to the Windows Operating System and the WMI repository. To find the serial number on a Mac or Linux machine, you would need to use a different method, such as checking the system's hardware inventory files or using a system-specific command like dmidecode on Linux.
Does this command work on all versions of Windows?
Yes, the Get-CimInstance cmdlet is available in Windows 7 with Service Pack 1, Windows 8, Windows 10, and Windows 11. It is also available on Windows Server 2008 R2 and later versions of the Windows Server operating system.
Why does the serial number look like Default string?
If the serial number field in the BIOS is empty or not populated by the hardware manufacturer, the command will return Default string. This is not a problem with the PowerShell command, but rather a configuration issue with the computer's firmware.
Is the serial number unique for every computer?
In theory, the serial number should be unique to each device. However, in practice, some manufacturers may reuse serial numbers or leave them blank. If you are using the serial number for asset tracking or warranty purposes, it is always a good idea to verify the information with the manufacturer's documentation.
Can I use this command to find the serial number of a laptop battery?
No, the Win32_BIOS class only provides information about the system's basic input/output system (BIOS) and does not include information about peripherals like batteries. To find information about a laptop battery, you would need to use a different class, such as Win32_Battery.