# Powershell list OS against txt file list

Hi guys, im trying to get the following list from a txt file i have but it returns all of the ad computers instead of the ones in the file. Any ideas?

thanks

$computers = Get-Content -Path C:\it\computers.txt Get-ADComputer -Filter * -Property * | Format-Table Name,OperatingSystem,OperatingSystemServicePack,OperatingSystemVersion -Wrap -Auto LVL 15 Asked: ###### Who is Participating? Senior Infrastructure Support Analyst & Systems DeveloperCommented: Try this:$computers = Get-Content -Path C:\it\computers.txt
foreach ($computer in$computers)
{
Get-ADComputer -Filter "name -eq '$computer'" -Property * | Format-Table Name,OperatingSystem,OperatingSystemServicePack,OperatingSystemVersion -Wrap -Auto } 0 Commented: Hi, It should be like, ForEach($Computer in Get-Content C:\it\computers.txt){Get-ADComputer \$Computer | Format-Table Name,SID -Wrap -Auto}

0

Author Commented:
perfect works great
0

Commented:
Above post beat me to it.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.