title: Output ("echo") a variable to a text file
body: <p>I'm running a PowerShell script against many servers, and it is logging output to a text file.</p>
  
  <p>I'd like to capture the server the script is currently running on. So far I have:</p>
  
  <pre><code>$file = "\\server\share\file.txt"
  $computername = $env:computername
  
  $computername | Add-Content -Path $file
  </code></pre>
  
  <p>This last line adds question marks in the output file. Oops.</p>
  
  <p>How do I output a variable to a text file in PowerShell?</p>