Die Ausgabe des Powershell-Exchange-Skripts funktioniert nur, wenn sie manuell eingegeben wird

Die Ausgabe des Powershell-Exchange-Skripts funktioniert nur, wenn sie manuell eingegeben wird

Ich gebe den folgenden Befehl in Exchange 2010 EMS ein und er funktioniert, wenn ich ihn interaktiv ausführe.

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

Wenn ich aus dem EMS-Fenster ein Skript aufrufe, das denselben Befehl enthält, erhalte ich Folgendes:

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

Ich bin mir nicht sicher, warum derselbe Befehl unterschiedliche Ergebnisse liefert. Irgendwelche Ideen? Danke.

Antwort1

Es scheint, dass die Pipeline-Ausgabe in einem Skript anders geändert wird als bei der manuellen Befehlseingabe. Die Antwort habe ich im folgenden Beitrag gefunden, in dem die Verwendung von „out-host“ erwähnt wird.

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

verwandte Informationen