Do i miss something or is it not possible to get my formatting in a Write-Debug statement?
"Date: {0:d}" -f (Get-Date) #Works as expected
Write-Debug "Date: {0:d}" -f (Get-Date) #Does not work
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Try changing $DebugPreference to “continue” and add some parens:
$DebugPreference = “Continue”
Write-Debug (“Date: {0:d}” -f (Get-Date))
The default for $DebugPreference is “SilentlyContinue” so Write-Debug won’t display anything.
Write-Host will just work if you enclose your message in the parens.