How To Get Serial Number From PowerShell: The Definitive Guide For Hardware Auditing And System Administration

How To Get Serial Number From PowerShell: The Definitive Guide For Hardware Auditing And System Administration

Serial Number Vs Thumbprint _ Find certificates using PowerShell - XVHQ

To retrieve a hardware serial number using PowerShell, administrative users should execute the Get-CimInstance command targeting the Win32_BIOS or Win32_ComputerSystemProduct classes to extract the SerialNumber property from the system firmware. This programmatic approach leverages the Common Information Model (CIM) to interface with the System Management BIOS (SMBIOS) data, providing a high-fidelity identifier essential for asset management, warranty verification, and remote fleet auditing.


Infrastructure Prerequisites and Administrative Configuration Standards

Before attempting to query hardware identifiers through the Windows Management Instrumentation (WMI) layer, an administrator must ensure the environment meets specific security and architectural standards. Hardware serial numbers are sensitive data points stored within the non-volatile RAM (NVRAM) of the motherboard, and accessing this layer requires elevated permissions to prevent unauthorized system profiling.

Technical requirements and baseline benchmarks for serial number extraction:



  • Mandatory User Rights: Local Administrative privileges or equivalent Remote Management Permissions (WinRM) are required. Standard user accounts may receive access denied errors or null values when querying the WMI repository.
  • PowerShell Version Compatibility: While legacy commands exist for version 2.0, this guide prioritizes PowerShell 5.1 (Desktop) and PowerShell 7.x (Core). The Get-CimInstance cmdlet is the modern standard, replacing the deprecated Get-WmiObject.
  • Protocol Requirements: For remote queries, the Windows Remote Management (WinRM) service must be active on the target machine, and the firewall must allow traffic on ports 5985 (HTTP) or 5986 (HTTPS).
  • Hardware Standards: The system must be SMBIOS compliant. Most enterprise hardware from vendors like Dell, HP, and Lenovo adheres to these standards, but custom-built white-box servers may lack properly populated BIOS strings.
  • Estimated Execution Time: Local retrieval takes less than 2 seconds; bulk remote retrieval for 100 nodes typically concludes within 45 to 60 seconds depending on network latency.

Strategic Workflows for Local and Remote Serial Number Extraction

The process of identifying a machine's unique serial number involves navigating the Common Information Model (CIM) hierarchy. The following steps outline how to isolate this data for single machines, remote targets, and specific hardware types like virtual machines.



Step 1: Initialize the PowerShell Session with Elevated Privileges

The retrieval of hardware-level data necessitates an elevated security context. Right-click the PowerShell icon and select Run as Administrator. If you are operating in a domain environment, ensure your account has the necessary Remote Management Users or Domain Admins membership. Once the terminal is open, verify your current identity by typing whoami to ensure you are operating under the correct credentials.



Step 2: Executing the Primary CIM Query for BIOS Data

The most reliable method for obtaining a serial number is querying the Win32_BIOS class. This class contains information specifically burned into the system's firmware by the Original Equipment Manufacturer (OEM).

To perform a basic query, type the command: Get-CimInstance Win32_BIOS.

The output will display several properties, including the SMBIOSBIOSVersion, Manufacturer, and the SerialNumber. In an enterprise environment where you only need the specific string for a script or database, you should pipe the command into a selection filter. Use the syntax: Get-CimInstance Win32_BIOS | Select-Object SerialNumber. This isolates the specific property and strips away unnecessary metadata, making it easier to read or export.

Pro-Tip: If you are working on older legacy systems where CIM is not fully supported, you may use the command Get-WmiObject Win32_BIOS. However, be aware that Get-WmiObject uses DCOM (Distributed Component Object Model) for remote connections, which is significantly more difficult to route through modern firewalls compared to the WSMAN protocol used by Get-CimInstance.



Step 3: Extracting Identifiers from the Computer System Product Class

In some scenarios, particularly with certain laptop manufacturers or virtualized environments, the BIOS serial number may return as a generic string or an empty value. In these cases, the Win32_ComputerSystemProduct class serves as a secondary authoritative source. This class often contains the IdentifyingNumber, which is functionally equivalent to the serial number in most asset management databases.

Execute the following: Get-CimInstance Win32_ComputerSystemProduct | Select-Object IdentifyingNumber, Name, Vendor.

This command provides a broader context, identifying the specific model name and the vendor alongside the serial identifier. This is particularly useful for distinguishing between different hardware revisions of the same product line.



Step 4: Performing Remote Fleet Audits via WinRM

One of PowerShell's primary strengths is its ability to query hundreds of machines simultaneously. To get the serial number from a remote computer, you must append the -ComputerName parameter to the Get-CimInstance command.

For a single remote target, use: Get-CimInstance Win32_BIOS -ComputerName TargetPC01 | Select-Object PSComputerName, SerialNumber.

Including the PSComputerName property is critical when querying multiple machines, as it allows you to map the serial number back to the specific hostname in your final report. For bulk operations involving a list of computers stored in a text file, you can utilize a variable: $Computers = Get-Content C:\Path\To\List.txt. You then pass this variable to the command: Get-CimInstance Win32_BIOS -ComputerName $Computers | Select-Object PSComputerName, SerialNumber.

Warning: If the remote machine is not configured for WinRM, the command will fail with a "Root\CIMV2 connection error." Ensure that the command Enable-PSRemoting -Force has been executed on all target machines via Group Policy or manual configuration before attempting bulk audits.



Step 5: Formatting and Exporting Data for Asset Management

Once the data is retrieved, it is rarely useful if it stays within the terminal window. To turn this raw data into a report, pipe the output to a CSV (Comma Separated Values) file. This allows for easy import into Excel or an IT Asset Management (ITAM) system.

Use the command: Get-CimInstance Win32_BIOS | Select-Object PSComputerName, SerialNumber, Manufacturer | Export-Csv -Path C:\Reports\HardwareInventory.csv -NoTypeInformation.

The -NoTypeInformation switch is vital as it prevents PowerShell from adding a header line that describes the object type, which often breaks third-party CSV parsers.


dotjesper.com | How to get Hyper-V guest serial number with PowerShell

dotjesper.com | How to get Hyper-V guest serial number with PowerShell

Comparison of Management Frameworks and Data Retrieval Methods

The table below provides a technical comparison of the three primary methods used to retrieve serial numbers within the Windows ecosystem. Selecting the correct method depends on the PowerShell version, security requirements, and the specific hardware architecture being queried.



Retrieval Method Primary Command Underlying Protocol Recommended Environment Data Reliability
CIM (Modern) Get-CimInstance WSMAN (HTTP/HTTPS) Windows 10/11 & Server 2016+ High (Industry Standard)
WMI (Legacy) Get-WmiObject DCOM / RPC Windows 7 & Server 2008 R2 Medium (Deprecated)
WMIC (Console) wmic bios get serialnumber Direct WMI Call Command Prompt / Batch Files Medium (Retiring)
Registry Get-ItemProperty Local Registry Access Systems with blocked WMI Low (May be altered)
ComputerSystem Get-CimInstance Win32_ComputerSystemProduct WSMAN Virtual Machines & Chassis High (For Model Data)

Resolving Common Data Discrepancies and Remote Execution Failures

Retrieving hardware data is not always a seamless process. Variances in OEM manufacturing and network security configurations can lead to several common failure states.



  • Failure Scenario: Output Returns "To Be Filled By O.E.M."



    • Root Cause: This occurs when a motherboard manufacturer fails to flash a unique serial number into the SMBIOS during production. This is extremely common in custom-built desktop PCs, white-box servers, or replacement motherboards that have not been initialized by a technician.
    • Actionable Fix: In these instances, try querying the Win32_BaseBoard class instead, using the command Get-CimInstance Win32_BaseBoard | Select-Object SerialNumber. If this also returns generic data, the physical chassis must be inspected for a manufacturer sticker, as the data simply does not exist in the firmware.
  • Failure Scenario: Access Denied (Error 0x80041003)



    • Root Cause: The user executing the PowerShell command lacks the necessary WMI permissions or is not running the shell as an administrator. This is a security feature to prevent low-privileged malware from profiling hardware.
    • Actionable Fix: Relaunch PowerShell with administrative rights. If querying remotely, ensure the executing user is part of the "Remote Management Users" group on the target machine and that the "Remote Enable" permission is granted in the WMI Control (wmimgmt.msc) security settings.
  • Failure Scenario: Serial Number Returns "VMWare-" or "None"



    • Root Cause: This is expected behavior for Virtual Machines. Hypervisors like VMware, Hyper-V, and VirtualBox generate synthetic serial numbers that follow a specific naming convention (e.g., VMware-42 1b...) rather than a hardware-bound string.
    • Actionable Fix: For virtual environments, focus on the UUID (Universally Unique Identifier) rather than the serial number. Use Get-CimInstance Win32_ComputerSystemProduct | Select-Object UUID to get a more reliable identifier for virtual assets.
  • Failure Scenario: RPC Server is Unavailable



    • Root Cause: Usually encountered when using legacy Get-WmiObject commands. The remote machine's firewall is blocking the dynamic ports required for DCOM communication, or the machine is offline.
    • Actionable Fix: Switch to Get-CimInstance, which uses the static port 5985 for WinRM. Ensure that the target machine is reachable via ping and that the WinRM service is running by executing Test-WSMan -ComputerName TargetName.

Frequently Asked Questions



Can I get the serial number without administrative privileges?

No, accessing the Win32_BIOS and Win32_ComputerSystemProduct classes requires elevated permissions because these queries interface directly with system firmware. Attempting to run these commands as a standard user will typically result in a null value or an "Access Denied" error message.



What is the difference between Win32_BIOS and Win32_BaseBoard?

Win32_BIOS retrieves the serial number assigned to the entire system by the OEM (like Dell or HP), which is what is usually used for warranty and support. Win32_BaseBoard retrieves the serial number of the specific motherboard component, which is useful if the motherboard was replaced or if you are dealing with a custom-built computer.



How do I get the serial number of a remote Mac or Linux machine using PowerShell?

PowerShell on non-Windows platforms does not use WMI/CIM. For Linux, you would use Invoke-Command to run "dmidecode -s system-serial-number" over SSH. For macOS, you would use "system_profiler SPHardwareDataType". PowerShell serves as the transport mechanism, but the underlying command must match the host's operating system.



Why does my serial number look like a long string of zeros?

Some manufacturers, particularly for budget-tier hardware or internal testing units, do not populate the serial number field. In other cases, if a motherboard is replaced by a third-party technician, they may forget to use the manufacturer's "tattoo" utility to write the original serial number into the new BIOS chip.



Is the PowerShell serial number the same as the Windows Product Key?

No, the hardware serial number is a unique identifier for the physical machine assigned by the manufacturer. The Windows Product Key (or Digital License) is a software-level credential used for operating system activation. These are stored in different locations and serve entirely different purposes.

Advance Your Infrastructure Management Strategy

Efficient hardware auditing is the foundation of a secure and organized IT environment. By mastering these PowerShell techniques, you can automate your inventory processes and ensure total visibility across your local and cloud-based assets.


How to Find Your Dell PPID: Locate Component Serial Numbers | Dell ...

How to Find Your Dell PPID: Locate Component Serial Numbers | Dell ...

Read also: Viral Digital Moments: Why the Interest in lena the plug gif is Surging in 2024