Can i use -Format Operator in Write-Host or Write-Debug?
Do i miss something or is it not possible to get my formatting in a Write-Debug statement?
"Date: {0:d}" -f (Get开发者_JAVA百科-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.
精彩评论