Write-Host And Write-Debug differently interpret double quotes

I have a string, that I wanted to output. I’ve tried Write-Debug and it caused error due to unescaped double quote.However when I used Write-Host, the same string was output successfully with unescaped double quotes just ignored.

$DebugPreference = “Continue”
Write-Host ” /cttDir=” \Base Config”  ”

Write-Debug ” /cttDir=” \Base Config”  ”

 /cttDir= \Base Config 

Write-Debug : A positional parameter cannot be found that accepts argument ‘\Base’.

At C:\Users\Temp\a15f78a2-cf2b-49b7-b6e7-bb7aef345639.ps1:3 char:1

+ Write-Debug ” /cttDir=”\Base Config”  ”

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidArgument: (:) [Write-Debug], ParameterBindingException

    + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.WriteDebugCommand.
For this purpose Write-Host is more convenient, but the right way to fix is to escape double quotes inside the string.


#powershell, #write-debug, #write-host