How to Get Serial Number in PowerShell: Easy Commands & Examples in 2026

Finding hardware serial numbers through PowerShell gives you quick, scriptable access to device information without opening multiple system menus. This guide shows you exactly how to retrieve serial numbers for computers, hard drives, monitors, and other hardware using simple PowerShell commands.

What Is a Serial Number and Why Get It Through PowerShell?

A serial number uniquely identifies your hardware device. Manufacturers assign these numbers to track warranties, support requests, and device authenticity.

PowerShell retrieves this information faster than traditional methods. Instead of opening Control Panel or physically checking device labels, you run one command and get instant results.

Common reasons to retrieve serial numbers:

  • Warranty claims and support tickets
  • IT asset management and inventory tracking
  • Remote computer identification
  • Hardware audit reports
  • Pre-deployment device verification
How to Get Serial Number in PowerShell

The Fastest Way to Get Your Computer Serial Number

Open PowerShell and run this single command:

Get-WmiObject Win32_BIOS | Select-Object SerialNumber

You’ll see output like this:

SerialNumber
------------
XXXX-XXXX-XXXX-XXXX

This pulls the serial number directly from your computer’s BIOS. It works on desktops, laptops, and servers running Windows.

Alternative Method Using CIM

Modern Windows systems support CIM (Common Information Model), which runs faster:

Get-CimInstance Win32_BIOS | Select-Object SerialNumber

Both commands produce identical results. CIM is newer and more efficient, but WMI works on older systems.

See also  Types of AI: A Complete Guide to Understanding AI Systems

How to Get Hard Drive Serial Numbers

Hard drives have separate serial numbers from your computer. This command retrieves them:

Get-WmiObject Win32_DiskDrive | Select-Object Model, SerialNumber

Output example:

ModelSerialNumber
Samsung SSD 980 PRO 1TBS5GXNX0R123456
WDC WD10EZEX-08M2NA0WD-WCC3F7654321

If you have multiple drives, this lists all of them with their corresponding models.

Filter Specific Drive Types

To see only SSDs or specific manufacturers:

Get-WmiObject Win32_DiskDrive | Where-Object {$_.Model -like "*SSD*"} | Select-Object Model, SerialNumber

This filters results to show only drives with “SSD” in the model name.

Getting Monitor Serial Numbers

Monitors also contain serial numbers embedded in their EDID data.

Get-WmiObject WmiMonitorID -Namespace root\wmi | Select-Object SerialNumberID

The output appears as ASCII character codes. Convert them to readable text:

$monitors = Get-WmiObject WmiMonitorID -Namespace root\wmi
foreach ($monitor in $monitors) {
    $serial = ($monitor.SerialNumberID | ForEach-Object {[char]$_}) -join ""
    Write-Output "Monitor Serial: $serial"
}

This loop processes each monitor and displays its serial number in plain text.

Remote Computer Serial Number Retrieval

PowerShell lets you query serial numbers from other computers on your network without physically accessing them.

Get-WmiObject Win32_BIOS -ComputerName "REMOTE-PC-NAME" | Select-Object SerialNumber

Replace “REMOTE-PC-NAME” with the actual computer name.

Query Multiple Computers at Once

Create a text file with computer names (one per line) and run:

$computers = Get-Content "C:\computers.txt"
foreach ($computer in $computers) {
    Get-WmiObject Win32_BIOS -ComputerName $computer | Select-Object PSComputerName, SerialNumber
}

This generates a list showing each computer name alongside its serial number.

Requirements for remote queries:

Creating a Complete Hardware Inventory Report

Combine multiple commands into a single report that captures all serial numbers:

$bios = Get-CimInstance Win32_BIOS
$disks = Get-CimInstance Win32_DiskDrive
$system = Get-CimInstance Win32_ComputerSystem

$report = [PSCustomObject]@{
    ComputerName = $system.Name
    Manufacturer = $system.Manufacturer
    Model = $system.Model
    BIOSSerial = $bios.SerialNumber
    Disks = $disks | ForEach-Object {"$($_.Model): $($_.SerialNumber)"}
}

$report | Format-List

This creates a structured object containing computer details and all hardware serial numbers.

Export to CSV for Documentation

Save your inventory to a spreadsheet:

$report | Export-Csv -Path "C:\hardware-inventory.csv" -NoTypeInformation

Open the CSV file in Excel for easy viewing and sharing.

Troubleshooting Common Serial Number Issues

Serial Number Shows as Blank or “To Be Filled By O.E.M.”

Some manufacturers don’t populate BIOS serial numbers properly, especially on:

  • Custom-built computers
  • Some budget laptops
  • Virtual machines
  • Cloned systems

Solution: Check the motherboard serial instead:

Get-WmiObject Win32_BaseBoard | Select-Object SerialNumber

Access Denied Errors on Remote Computers

If you receive “Access is denied” errors:

  1. Verify you have admin rights on the target computer
  2. Check if WinRM is running: Test-WSMan -ComputerName "REMOTE-PC"
  3. Enable PowerShell remoting: Enable-PSRemoting -Force

Hard Drive Serial Contains Extra Spaces

Some drives return serials with leading/trailing spaces. Clean them:

Get-WmiObject Win32_DiskDrive | Select-Object Model, @{Name="SerialNumber";Expression={$_.SerialNumber.Trim()}}

The .Trim() method removes unnecessary whitespace.

See also  Best Practices for Responsive Web Design in 2026: Complete Guide

Advanced Serial Number Techniques

Get Serial Numbers from Specific Hardware Components

Processor serial (if available):

Get-WmiObject Win32_Processor | Select-Object ProcessorId

Memory module serials:

Get-WmiObject Win32_PhysicalMemory | Select-Object Manufacturer, SerialNumber, Capacity

Network adapter MAC addresses:

Get-NetAdapter | Select-Object Name, MacAddress

Schedule Automated Inventory Collection

Create a scheduled task that runs monthly and emails results:

$report = Get-CimInstance Win32_BIOS | Select-Object SerialNumber
$report | Export-Csv "C:\Reports\Serial_$(Get-Date -Format 'yyyy-MM-dd').csv"

# Add email notification code here

This maintains historical records of your hardware inventory.

Understanding WMI vs. CIM Commands

PowerShell offers two similar methods for querying hardware information:

FeatureWMI (Get-WmiObject)CIM (Get-CimInstance)
Windows versionWorks on all versionsWindows 8/Server 2012+
PerformanceSlowerFaster
ProtocolDCOMWS-Man
Remote queriesRequires DCOM portsUses standard HTTP/HTTPS
Future supportLegacyRecommended

Microsoft recommends using CIM cmdlets for new scripts. They’re faster and more secure. However, WMI commands still work if you need backward compatibility with older systems.

For detailed comparisons, see the PowerShell documentation at https://learn.microsoft.com/en-us/powershell/scripting/learn/ps101/07-working-with-wmi.

Creating Reusable PowerShell Functions

Turn your serial number queries into functions you can call anytime:

function Get-ComputerSerial {
    param(
        [string]$ComputerName = $env:COMPUTERNAME
    )
    
    try {
        $bios = Get-CimInstance Win32_BIOS -ComputerName $ComputerName -ErrorAction Stop
        return $bios.SerialNumber
    }
    catch {
        Write-Error "Failed to get serial for $ComputerName: $_"
        return $null
    }
}

# Use it like this:
Get-ComputerSerial
Get-ComputerSerial -ComputerName "SERVER01"

Save this function in your PowerShell profile to access it in every session.

Add the Function to Your Profile

Find your profile location:

$PROFILE

Edit it:

notepad $PROFILE

Paste the function code and save. Now Get-ComputerSerial works in every new PowerShell window.

Serial Numbers in Virtual Environments

Virtual machines handle serial numbers differently than physical hardware.

VMware VMs:

Get-WmiObject Win32_BIOS | Select-Object SerialNumber

Returns the VM’s unique identifier, not the host’s serial.

Hyper-V VMs:

Often shows generic values. Check the VM configuration in Hyper-V Manager instead.

Cloud instances (Azure, AWS):

These platforms provide instance IDs rather than traditional serial numbers:

# Azure VM
Invoke-RestMethod -Headers @{"Metadata"="true"} -Method GET -Uri "http://169.254.169.254/metadata/instance?api-version=2021-02-01" | Select-Object -ExpandProperty compute | Select-Object vmId

Using Serial Numbers for License Management

Many software licenses tie to hardware serial numbers. PowerShell automates license compliance checking:

$serial = (Get-CimInstance Win32_BIOS).SerialNumber
$expectedSerial = "AUTHORIZED-SERIAL-123"

if ($serial -eq $expectedSerial) {
    Write-Output "License valid for this machine"
} else {
    Write-Output "License mismatch - contact IT"
}

This script verifies software runs only on authorized hardware.

See also  How to Set Up Parental Controls on Windows 11/10 (2026 Guide)

Formatting Serial Number Output

Make your results more readable with custom formatting:

Get-CimInstance Win32_BIOS | Format-Table @{
    Label="Computer Serial Number"
    Expression={$_.SerialNumber}
}, @{
    Label="BIOS Version"
    Expression={$_.SMBIOSBIOSVersion}
} -AutoSize

Creates a clean table with custom column headers.

Color-Coded Output

Add visual indicators for quick scanning:

$serial = (Get-CimInstance Win32_BIOS).SerialNumber

if ($serial -match "^[A-Z0-9]") {
    Write-Host "Valid Serial: $serial" -ForegroundColor Green
} else {
    Write-Host "Check Serial: $serial" -ForegroundColor Yellow
}

Green text confirms valid formats, yellow highlights potential issues.

Best Practices for Serial Number Management

Security considerations:

Never store serial numbers in plain text files on shared drives. Use encrypted storage or secure databases for sensitive hardware inventories.

Documentation standards:

Create consistent naming conventions for your export files:

$date = Get-Date -Format "yyyy-MM-dd"
$hostname = $env:COMPUTERNAME
$filename = "HW-Inventory_${hostname}_${date}.csv"

This generates descriptive filenames like “HW-Inventory_LAPTOP01_2026-02-04.csv”.

Regular audits:

Schedule quarterly comparisons between recorded and actual serial numbers to detect hardware swaps or theft.

Summary and Conclusion

PowerShell provides quick, scriptable access to hardware serial numbers across your entire Windows infrastructure. The basic command Get-CimInstance Win32_BIOS | Select-Object SerialNumber gets your computer’s serial in seconds.

For comprehensive hardware tracking, combine BIOS, disk, and component queries into automated reports. Use CIM cmdlets on modern systems for better performance, and create reusable functions to streamline repetitive tasks.

Key takeaways:

  • Get-CimInstance Win32_BIOS retrieves computer serial numbers
  • Get-CimInstance Win32_DiskDrive lists all hard drive serials
  • Remote queries require WinRM and administrator access
  • Export results to CSV for documentation and auditing
  • CIM cmdlets outperform legacy WMI commands

Whether you manage a single computer or thousands of devices, PowerShell’s serial number capabilities save time and improve inventory accuracy. Start with simple queries, then build more sophisticated automation as your needs grow.

Frequently Asked Questions

How do I get a laptop serial number using PowerShell?

Use the same command as desktop computers: Get-CimInstance Win32_BIOS | Select-Object SerialNumber. This works identically on laptops, desktops, and servers. The serial number is stored in the BIOS/UEFI firmware regardless of form factor.

Can PowerShell retrieve serial numbers without administrator rights?

Yes, reading local computer serial numbers works with standard user privileges. However, querying remote computers or accessing certain hardware components requires administrator rights. If you encounter “Access Denied” errors, run PowerShell as administrator.

What if the serial number shows as “Default string” or blank?

Some manufacturers don’t populate the BIOS serial field, especially on custom-built PCs or virtual machines. Try alternative sources: Get-CimInstance Win32_BaseBoard | Select-Object SerialNumber for motherboard serial, or check individual component serials instead of relying on the system BIOS.

How do I get serial numbers from all computers in Active Directory?

Query Active Directory for computer names, then loop through them: Get-ADComputer -Filter * | ForEach-Object { Get-CimInstance Win32_BIOS -ComputerName $_.Name | Select-Object PSComputerName, SerialNumber }. This requires the Active Directory module and appropriate permissions.

Can I get iPhone or Android device serial numbers through PowerShell?

No, PowerShell only accesses Windows hardware information. For mobile devices, use platform-specific tools like Apple Configurator for iOS or ADB (Android Debug Bridge) for Android devices. PowerShell cannot query non-Windows operating systems directly.

MK Usmaan