我在 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
时,代码可以工作。
最佳答案
虽然我无法仅用这一个命令在此处重现该错误,但该错误看起来像是由于 PowerShell 格式化子系统无法处理多个对象类型(由于单个格式化操作)而导致的错误。与人们的想法相反 - Format-table
实际上结果对象和 Out-Default
输出端自动执行的操作将会丢失。
我想知道执行此脚本是否对您本身不起作用,或者只是在较大脚本的上下文中出现问题?
我首先尝试的是附加 | Out-String | Out-Default
在管道的末端。其实甚至| Out-String
应该有帮助。
关于c# - 由于使用 sitecore 的对象的当前状态,该操作无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35212429/