我在sitecore powershell上运行此代码,以便在路径中创建新的语言文件:
Get-ChildItem "master:\Print Studio\Print Studio Projects\Maax Product Catalogs\Prof CAN Catalog T2\Books\P_Book\Documents\Full Catalog FR\Pages\Prof-FSBathtubsSectionSnippet\" -Recurse -Language "en" | `
Add-ItemLanguage -TargetLanguage "fr-CA" -IfExist Append | `
Format-Table Name, Language, Version -auto
使用时-Recurse
我收到此错误
The object of type "Microsoft.PowerShell.Commands.Internal.Format.FormatStartData" is not valid or does not appear in the correct order. The reason is probably a conflict between an order "format-list" specified by the user and default formatting.
Of type: System.Management.Automation.CmdletInvocationException
Stack trace:
to System.Management.Automation.Internal.PipelineProcessor.DoStepItems (Object input, errorResults Hashtable, Boolean enumerate)
to Microsoft.PowerShell.Commands.Internal.Format.CommandWrapper.Process (Object o)
to Microsoft.PowerShell.Commands.Internal.Format.SubPipelineManager.Process (PSObject so)
to Microsoft.PowerShell.Commands.Internal.Format.OutputManagerInner.ProcessRecord ()
to Microsoft.PowerShell.Commands.Internal.Format.FrontEndCommandBase.ProcessRecord ()
to System.Management.Automation.CommandProcessor.ProcessRecord ()
Inner Exception: The operation is not valid due to the current state of the object.
Of type: System.InvalidOperationException
Stack trace:
to System.Management.Automation.MshCommandRuntime.ThrowTerminatingError (ErrorRecord ErrorRecord)
当不使用-Recurse
时,代码可以正常工作。
答案 0 :(得分:4)
虽然我不能在这里只用这一个命令重现它错误看起来像是因为PowerShell格式化子系统因为无法处理多个对象类型而得到的错误单一格式化操作。与人们可能认为的相反 - Format-table
实际上是结果对象,并且在输出端自动执行的Out-Default
操作将丢失。
我想知道这个脚本的执行是否对你自己没有用,或者它只是一个大脚本环境中的问题?
我首先尝试的是在管道末尾添加| Out-String | Out-Default
。实际上即使| Out-String
也应该有帮助。