2016-02-04 60 views
2

我爲了在路徑創建新的語言文件運行Sitecore的PowerShell中代碼的對象的當前狀態:操作無效由於使用Sitecore的

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

'@(GET-ChildItem ... |添加-ItemLanguage ...)|格式Table' –

+0

我會用'的Get-更換'格式Table'開始進行故障排除Member'。通過這種方式,您可以確認哪些對象通過管道傳遞到輸出命令。您也可能希望輸出所有字段,並確保您沒有任何重複的字段名稱。 – Coding101

回答

4

雖然我不能僅此一個命令錯誤看起來像一個我正在爲PowerShell中的格式化子系統無法處理多個對象類型爲單格式化操作的結果,因此在這裏重現。與人們可能認爲的相反 - Format-table實際上結果對象和在輸出端自動執行的Out-Default操作將丟失。

我不知道這個腳本的執行是不是對你自己有用,還是它只是一個大腳本的問題?

我想先嚐試的是在管道末尾追加| Out-String | Out-Default。其實即使| Out-String應該有所幫助。

相關問題