
我在 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”的使用。