title: With PowerShell, how can I get Write-Debug output to appear in the console?
body: <p>I'm learning PowerShell and was using <a href="https://docs.microsoft.com/en-gb/powershell/module/Microsoft.PowerShell.Utility/Write-Host" rel="noreferrer">Write-Host</a> to check variable assignments in a new PowerShell script file. Then I read an article suggesting this was a bad idea.</p>
  
  <p>So, in my .ps1 file I replaced statements like this:</p>
  
  <pre><code>Write-Host "Start"
  Write-Host "End"
  </code></pre>
  
  <p>... with this:</p>
  
  <pre><code>Write-Debug "Start"
  Write-Debug "End"
  </code></pre>
  
  <p>But when I ran the saved script in Windows PowerShell ISE no output was written to the console. I appended <code>-debug</code> to the statement that calls the script, like so:</p>
  
  <pre><code>PS E:\trialrun&gt; .\MyScript.ps1 -debug
  </code></pre>
  
  <p>But again, the output doesn't get written to the console. Apparently I'm using Write-Debug incorrectly.  How can I get the debug output to write to the console?</p>