I am trying to get the Server OU location from a list of server. The code I wrote works but dose not seem to be very efficient. Is there a better way of coding this?
Thanks in advance.
$servers = Get-Content c:\serverlist.txt
foreach ($serv in $servers)
$result = Get-ADComputer -server dc2 $serv | select distinguishedname
$result | ft -AutoSize | Out-File c:\result.txt -Append