考虑脚本“test.ps1”:
Get-EventLog -list | gm
当从Powershell控制台调用(“.\test.ps1”)时,它会按预期输出成员。
然而,以下脚本没有显示“Get-EventLog -list | gm”的输出:
脚本1
Get-EventLog -list | gm
break
脚本 2
Get-EventLog -list | gm
$yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes", "Continua execucao"
$no = New-Object System.Management.Automation.Host.ChoiceDescription "&No", "Cancela operacao"
$options = [System.Management.Automation.Host.ChoiceDescription[]]($yes, $no)
$result = $host.ui.PromptForChoice("Title", "Message", $options, 0)
如果我把“Get-EventLog -list | gm”改成像“Hello World”这样的文本,它会正确地显示,两种情况都是如此。为什么cmdlet的输出没有显示?
Get-EventLog -list | gm | out-host
。 - CB.