考虑脚本“test.ps1:
Get-EventLog -list | gm
Run Code Online (Sandbox Code Playgroud)
当从 Powershell 控制台(“.\test.ps1”)调用它时,它会按预期输出成员。
但是,以下脚本不显示“Get-EventLog -list | gm”的输出:
脚本1
Get-EventLog -list | gm
break
Run Code Online (Sandbox Code Playgroud)
脚本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)
Run Code Online (Sandbox Code Playgroud)
如果我将“Get-EventLog -list | gm”更改为“Hello World”等文本,则在两种情况下都会正确显示。
为什么不显示 cmdlet 的输出?
| 归档时间: |
|
| 查看次数: |
5164 次 |
| 最近记录: |