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 to configure WinRM by using Group Policy:

https://social.technet.microsoft.com/wiki/contents/articles/33634.enable-powershell-remoting-via-group-policy-on-windows7windows-server-2008-r2.aspx

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

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 )

Google+ photo

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

Twitter picture

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

Facebook photo

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

w

Connecting to %s