我试图运行下面的代码来检索一台机器上的本地用户列表。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