«

»

Jul 30

How To: Get serial number from a list of servers or computers

Description:
This How To will help you get the serial number from a list of servers or computers. The list of servers or computers would be provide in a txt file.

 
How To:

$colItems = get-wmiobject -class "Win32_BIOS" -computername (Get-Content c:\computers.txt)
foreach ($objItem in $colItems) {
   $computername = $objItem.__SERVER
   Write-Host $computername "," $objItem.SerialNumber
}


Explanation:

$colItems = get-wmiobject -class "Win32_BIOS" -computername (Get-Content c:\computers.txt)

This script use WMI to get the serial number from the server. It open the class Win32_BIOS for the computers or server in the txt file computers.txt.

foreach ($objItem in $colItems) {
   $computername = $objItem.__SERVER
   Write-Host $computername "," $objItem.SerialNumber
}

For each computers in computers.txt the script will write in the powershell windows the name of the computer and the serial number of that computer.

Please feel free to use the comments section for any questions or if you find any bug in this post.

1 comment

  1. Marco

    it didn’t work for me getting Code Error 800A0408 – Invalid Character

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>