信息记录被打印两次

时间:2019-05-19 13:56:34

标签: powershell

为什么下面的代码两次打印信息消息?信息流是否具有某些独特的属性?

$VerbosePreference = 'Continue'
$InformationPreference = 'Continue'
$WarningPreference = 'Continue'

$sb = {
    $VerbosePreference = 'Continue'
    $InformationPreference = 'Continue'
    $WarningPreference = 'Continue'

    Write-Verbose 'verbose'
    Write-Information 'information'
    Write-Warning 'warning'
}

$job = Start-Job -ScriptBlock $sb
Wait-Job $job | Out-Null
Receive-Job $job

输出:

VERBOSE: verbose
information
information
WARNING: warning

默认情况下,我知道$InformationPreference='SilentlyContinue',如果在脚本块的内部或外部将其更改为默认值,我将获得一次打印的信息记录。

0 个答案:

没有答案