2

I would like to get the serial numbers of a list of computers. I have created a powershell script as follows:


$computers = Get-Content c:\pstest\computerlist.txt

Get-wmiobject win32_bios | ForEach-Object {$_.serialnumber}

All I get is as follows:

PS C:\pstest> .\pstest01.ps1
R6Z00180

How do I do this ?

3 Answers 3

3

The ComputerName parameter accepts a collecion of names so you can pass the content of the file to it:

$computers = Get-Content c:\pstest\computerlist.txt
Get-wmiobject Win32_Bios -ComputerName $computers | Select-Object __SERVER, SerialNumber
Sign up to request clarification or add additional context in comments.

Comments

0

Get-WmiObject has a -ComputerName parameter:

$computers | foreach { (Get-WmiObject Win32_BIOS -Computername $_).SerialNumber }

Comments

0

Elaborating on Shay's answer. If you insist to have everything in a single pipeline:

Get-WmiObject Win32_Bios -ComputerName (Get-Content c:\pstest\computerlist.txt) | 
Select-Object __SERVER, SerialNumber

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.