PowerShell

Get serial numbers of all Domain Computers with PowerShell

Some time ago one of my LinekIn contacts and group member of my LinkedIn Group PowerShell Engineers posted a One-Liner that gets the serial number of the local computer. Thank you for the tip and suggestion. After some thoughts I came to the idea trying to retreive all serial numbers from all computers of my domain. Let’s keep this in form of this blog post and share with others …

Introduction

To get the serial number of your computer open Windows PowerShell and run

wmic bios get serialnumber

1.PNG

Or use Get-WmiObject.

Get-WmiObject win32_bios | Select Serialnumber

1.PNG

There’s more. Another way is using Get-CimInstance.

Get-CimInstance Win32_Bios | Select-Object SerialNumber

1.PNG

Prerequisites

My goal is to retrieve all Serial Numbers in a user friendly and easy to read output. Make sure that WinRM is enabled on all remote computers (Windows Server 2012/2016 enabled by default, Windows Client disabled by default). For testing you could enable it by running Enable-PSRemoting in Windows PowerShell. For large environments, I recommend configuring WinRM by using Group Policy:

Group Policies: Enabling WinRM for Windows Client Operating Systems (Windows 10, Windows 8, Windows 7)

Aaaand … Action!

All computers must share the same Active Directory Domain. I am logged on to one of my Domain Controller. Here is a One-Liner which gives me all serial numbers of all computers:

(Get-ADComputer -Filter *).Name | Foreach-Object {Get-CimInstance Win32_Bios -ComputerName $_ -ErrorAction SilentlyContinue | Select-Object PSComputerName,SerialNumber}

Unbenannt.PNG

For a more user-friendly view and output use Out-GridView …

Unbenannt.PNG

And if you don’t like the headlines (f.e. PSComputerName), simply modify them …

(Get-ADComputer -Filter *).Name | Foreach-Object {Get-CimInstance Win32_Bios -ComputerName $_ -ErrorAction SilentlyContinue | Select-Object @{n='Computername'; e={$_.PSComputerName}},SerialNumber}

Unbenannt.PNG

Conclusion

This scenario is definitely not a replacement for an enterprise solution such as SCCM. We can get only serial numbers from switched on computers. With SCCM all computer report their status on a time based routine to the SCCM Server which is much more comfortable, useful and up to date.

See also

More about documenting remote computers see also my articles …

PowerShell: Documenting your environment by running systeminfo on all Domain-Computers

Windows Server: List all installed Roles and Features using PowerShell

9 replies »

  1. Hey @Partrick,
    Loved this info! Thanks!
    I was wondering if we could get computer name mapped against user name.
    I am looking to get information of the current system that every user in my domain is logged on (computer name / serial number), but found no command that could give me this output.
    Can you share your expertise?
    Thanks!

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.