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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With