PowerShell Exchange スクリプトの出力は手動で入力した場合にのみ機能します

PowerShell Exchange スクリプトの出力は手動で入力した場合にのみ機能します

Exchange 2010 EMS で次のコマンドを入力し、対話的に実行すると機能します。

$a = Get-MailboxDatabaseCopyStatus -server theName | fl name,activedatabasecopy,status,contentindexstate
Write-Host $a

EMS ウィンドウ内から同じコマンドを持つスクリプトを呼び出すと、次の結果が出力されます。

Microsoft.PowerShell.Commands.Internal.Format.FormatStartData Microsoft.PowerShell.Commands.Internal.Format.GroupStartData Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData Microsoft.PowerShell.Commands.Internal.Format.GroupEndData Microsoft.PowerShell.Commands.Internal.Format.FormatEndData

同じコマンドが異なる出力を出す理由がわかりません。何かアイデアはありますか? ありがとうございます。

答え1

パイプライン出力は、スクリプトと手動のコマンド入力では異なる方法で変更されるようです。「out-host」の使用について言及している以下の投稿で答えを見つけました。

https://stackoverflow.com/questions/35780815/exchange-get-mailbox-output-different-in-script-vs-command-line

関連情報