title: powershell output results from a script to log file
body: <p>I have a simple bit of Powershell code which pings servers if they are up and then disables the local admin account. How can I output the results to a log file so that I have record of what I have disabled. </p>
  
  <p>This is what I have so far </p>
  
  <pre><code>$computers = Get-ADComputer -filter {OperatingSystem -like "Windows Server*"} | 
  ForEach ($computer in $computers) {     
     $rtn = Test-Connection -CN $computer -Count 1 -BufferSize 16 -Quiet    
    IF($rtn -match 'True') {
      write-host -ForegroundColor green $computer | Disable-localUserAccount -ComputerName $computer -username Administrator
    } ELSE {
        Write-host -ForegroundColor red $computer
    }     
  }
  </code></pre>