我試圖運行下面的代碼來檢索一臺機器上的本地用戶列表。Powershell格式表錯誤
The object of type "Microsoft.PowerShell.Commands.Internal.Format.FormatStartData" is not valid or not in the correct sequence. This is likely caused by a user-specified "f ormat-table" command which is conflicting with the default formatting. + CategoryInfo : InvalidData: (:) [out-lineoutput], InvalidOperationException + FullyQualifiedErrorId : ConsoleLineOutputOutOfSequencePacket,Microsoft.PowerShell.Commands.OutLineOutputCommand
我理解這個問題的產生是因爲方式的管道被分析,但是我不能想出如何繞過它:
gwmi win32_useraccount -Computername $env:computername -Filter "Domain='$env:computername'" |
Format-Table Name,Description
我一個PS1文件中運行時出現此錯誤。
原始命令對我來說不會出錯。是什麼賦予了? – manojlds
我不會用這個命令重現我的七個,但是它會追加到其他WMI類中。 – JPBlanc
@manojlds在單個執行中一起運行多個輸出生成語句時,問題就出現了。通過在命令行上使用';'語句分隔符將兩個命令組合在一起,可以在命令行上獲得相同的結果。在某些情況下它有效,在另一些情況下則不行。但強制輸出是直接顯示的字符串一直對我有用。 – Richard