We help IT Professionals succeed at work.

Determine PC Model and Serial of remote computers with command line or Powershell

J Muro
J Muro asked
on
Hi everyone!

I have a list of PC hostnames on a spreadsheet which users are logged into daily. I have no other information as to the model of the PCs etc.
Is there a way from the command line/PowerShell or a tool I could use to determine this information without having to interrupt and without user knowing?

The main goal is to find out the Serial number of each PC, bonus would be  knowing which OS etc running etc.

Hope that makes sense!

Many Thanks :)
Comment
Watch Question

ZvonkoSystems architect
Top Expert 2006

Commented:
wmic csproduct get vendor, version


wmic bios get serialnumber
ZvonkoSystems architect
Top Expert 2006

Commented:

And here the powershell script:

(Get-Content C:\Zvonko\computerList.txt).Trim() | ForEach { 
	$Computer = $_ 
	If (Test-Connection -ComputerName $Computer -Count 1 -Quiet) { 
	 	Write-Host "Computer: $Computer" 
		$Sytem = Get-WmiObject Win32_ComputerSystem -Computer $Computer 
		$Bios = Get-WmiObject Win32_Bios -Computer $Computer 
		$props = @{ 
			ComputerName = $Computer 
			Manufacturer = $Sytem.Manufacturer 
			Model = $Sytem.Model 
			SerialNumber = $Bios.SerialNumber 
		}  
        New-Object PsObject -Property $props  
    } Else { 
        Write-Warning "Computer $Computer cannot be reached, skipping." 
    } 
} | Sort ComputerName | 
	Select ComputerName,Manufacturer,Model,SerialNumber | 
	Export-Csv C:\Zvonko\computerDetails.csv -NoTypeInformation


Author

Commented:
Thanks for your message Zvonko. Apologies, I did not phrase my question correctly. With the commands that you provided I would like achieve the below:

I have a list of PC hostnames on a spreadsheet which users are logged into daily. I have no other information as to the model of the PCs etc.
Is there a way from the command line/PowerShell or a tool I could use to determine this information without having to interrupt and without user knowing?

The main goal is to find out the Serial number of each PC, bonus would be  knowing which OS etc running etc.

Hope that makes sense!
Systems architect
Top Expert 2006
Commented:

Copy the column from your spreadsheedt with the ComputerNames.

Place that list of ComputerNames into this file:

 C:\Zvonko\computerList.txt

Copy my Powershell-Script form my previous comment into a script file, lets name it: getSerialNumbers.ps1


Then call this script like this:

C:\Zvonko>powershell -f getSerialNumbers.ps1

The Powershell script  getSerialNumbers.ps1 will produce this file;

C:\Zvonko\computerDetails.csv


Does this help you?



ZvonkoSystems architect
Top Expert 2006

Commented:

PS. If you attach one such spreadsheet file here then I can change my script to read directly your ComputerNames column  :  )

Author

Commented:
That is exactly what I needed!

Thank you Zvonko! :)

J.
ZvonkoSystems architect
Top Expert 2006

Commented:

You are welcome.