Reputation: 598
$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
Reputation: 2676
You forgot this part. Happens to the best of us.
-ComputerName $Computer
(Get-CIMInstance -ComputerName $Computer CIM_ComputerSystem).Name
Upvotes: 1