title: Listing local administrator group membership on all domain computers
body: <p>Complete powershell and scripting noob here - I don't even know enough to be dangerous.  I need to query all PCs in the domain to determine what their local Administrators group membership is and send that output to a text/csv file.</p>
  
  <p>I've tried numerous things like:</p>
  
  <pre><code>Import-Module -Name ActiveDirectory
  Get-ADComputer -filter * |
  Foreach-Object {
   invoke-command {net localgroup administrators} -EA silentlyContinue |
  } |
  Out-File c:\users\ftcadmin\test.txt
  </code></pre>
  
  <p>Which gets me an identical list repeated but seems to be hitting every domain PC.  I'm guessing it's not actually running on the remote PCs though.  Also tried:</p>
  
  <pre><code>$computers = Get-Content -Path c:\users\ftcadmin\computers.txt
  invoke-command {net localgroup administrators} -cn $computers -EA silentlyContinue
  Get-Process | Out-File c:\users\ftcadmin\test.txt
  </code></pre>
  
  <p>which is limited by predetermined list of PCs in the computers.txt file.  A third thing I tried was this:</p>
  
  <pre><code>$a = Get-Content "C:\users\ftcadmin\computers.txt"
  Start-Transcript -path C:\users\ftcadmin\output.txt -append
  foreach ($i in $a)
    { $i + "`n" + "===="; net localgroup "Administrators"}
  Stop-Transcript
  </code></pre>
  
  <p>which seems to have the most potential except the output is just</p>
  
  <pre><code>computername1
  ====
  computername2
  ====
  </code></pre>
  
  <p>etc without any listing of the group members.</p>
  
  <p>Any ideas from the community?</p>