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
Or use Get-WmiObject.
Get-WmiObject win32_bios | Select Serialnumber
There’s more. Another way is using Get-CimInstance.
Get-CimInstance Win32_Bios | Select-Object SerialNumber
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:
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}
For a more user-friendly view and output use Out-GridView …
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}
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
Categories: PowerShell, Windows Server
how we can get all the serial pc, monitor an docking station of a user in Powershell?
LikeLike
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!
LikeLike
Try out my script get all logged on users.
LikeLike
Hey @Partick,
I assume you are talking about this script:
https://sid-500.com/2018/02/28/powershell-get-all-logged-on-users-per-computer-ou-domain-get-userlogon/
I used this script but it did not give me any output.
What could be gone wrong?
LikeLike
Maybe you should check WinRM on client computers?
LikeLike
Maaaan. i just love you:D helped much.
LikeLiked by 1 person
Thank you!
LikeLike
is it possible to return Hostname/IP Address using serialnumber in windows domain.
LikeLike