开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜