title: Output PowerShell variables to a text file
body: <p>I'm new to PowerShell and have a script which loops through Active Directory searching for certain computers. I get several variables and then run functions to check things like <a href="https://en.wikipedia.org/wiki/Windows_Management_Instrumentation" rel="noreferrer">WMI</a> and registry settings.</p>
  
  <p>In the console, my script runs great and simple <a href="https://msdn.microsoft.com/powershell/reference/5.1/microsoft.powershell.utility/Write-Host" rel="noreferrer">Write-Host</a> command prints the data on the screen as I want. I know about <a href="https://msdn.microsoft.com/powershell/reference/5.1/microsoft.powershell.utility/Export-Csv" rel="noreferrer">Export-Csv</a> when using the pipeline...but I'm not looking to print from the pipeline.</p>
  
  <p>I want to write the variables to a text file, continue the loop, and check the next computer in AD...output the next iteration of the same variables on the next line. Here is my Write-Host:</p>
  
  <pre><code>Write-Host ($computer)","($Speed)","($Regcheck)","($OU)
  </code></pre>
  
  <p>Output file:</p>
  
  <pre><code>$computer,$Speed,$Regcheck | out-file -filepath C:\temp\scripts\pshell\dump.txt -append -width 200
  </code></pre>
  
  <p>It gives me the data, but each variable is on its own line. Why? I'd like all the variables on one line with comma separation. Is there a simple way to do this akin to VB writeline? My PowerShell version appears to be 2.0.</p>