title: How do I add a newline to command output in PowerShell?
body: <p>I run the following code using PowerShell to get a list of add/remove programs from the registry:</p>
  
  <pre><code>Get-ChildItem -path hklm:\software\microsoft\windows\currentversion\uninstall `
      | ForEach-Object -Process { Write-Output $_.GetValue("DisplayName") } `
      | Out-File addrem.txt
  </code></pre>
  
  <p>I want the list to be separated by newlines per each program. I've tried:</p>
  
  <pre><code>Get-ChildItem -path hklm:\software\microsoft\windows\currentversion\uninstall `
      | ForEach-Object -Process { Write-Output $_.GetValue("DisplayName") `n } `
      | out-file test.txt
  
  Get-ChildItem -path hklm:\software\microsoft\windows\currentversion\uninstall `
      | ForEach-Object {$_.GetValue("DisplayName") } `
      | Write-Host -Separator `n
  
  Get-ChildItem -path hklm:\software\microsoft\windows\currentversion\uninstall `
      | ForEach-Object -Process { $_.GetValue("DisplayName") } `
      | foreach($_) { echo $_ `n }
  </code></pre>
  
  <p>But all result in weird formatting when output to the console, and with three square characters after each line when output to a file. I tried <code>Format-List</code>, <code>Format-Table</code>, and <code>Format-Wide</code> with no luck. Originally, I thought something like this would work:</p>
  
  <pre><code>Get-ChildItem -path hklm:\software\microsoft\windows\currentversion\uninstall `
      | ForEach-Object -Process { "$_.GetValue("DisplayName") `n" }
  </code></pre>
  
  <p>But that just gave me an error.</p>