Royston
Royston

Reputation: 598

Trying to return info on computer names for test

    $computers = Get-Content C:\computers.txt #| Where-Object { $_ } 

foreach ($computer in $computers) {


     (Get-CIMInstance CIM_ComputerSystem).Name

      }

Why is the above code only returning the local computer name, shouldnt it select the computers in the text file and return their computer names?

Upvotes: 0

Views: 48

Answers (1)

Sid
Sid

Reputation: 2676

You forgot this part. Happens to the best of us.

-ComputerName $Computer

(Get-CIMInstance -ComputerName $Computer CIM_ComputerSystem).Name

Upvotes: 1

Related Questions