スクリプト「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」を「HelloWorld」のようなテキストに変更すると、どちらの場合も正しく表示されます。
コマンドレットからの出力が表示されないのはなぜですか?