由于使用 sitecore 的对象处于当前状态,该操作无效

本文关键字:状态 操作 无效 于当前 于使用 sitecore 对象 | 更新日期: 2023-09-27 18:33:21

我在 sitecore powershell 上运行此代码,以便在 path 中创建新的语言文件:

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代码有效。

由于使用 sitecore 的对象处于当前状态,该操作无效

虽然我不能只用这个命令在这里重现它,但错误看起来像是我得到的错误,因为 PowerShell 格式化子系统由于单个格式化操作而无法处理多种对象类型。与人们的想法相反 - Format-table实际上结果对象和在输出端自动执行的Out-Default操作将丢失。

我想知道执行此脚本本身是否对您不起作用,或者它只是在较大脚本的上下文中存在问题?

我首先尝试的是将| Out-String | Out-Default附加到管道的末尾。实际上,即使是| Out-String也应该有所帮助。

  • 一些进一步的提示
相关文章: