Sitecore - Powershell Extensions Script To Update Workflow State
Recently I got a client that imported Spanish versions of all the items using the Sitecore OOTB language importer, and for obvious reasons, the associated workflow state for each version was set to the initial step. For environments like UAT or PROD we don't want to automatically approve these versions, however, for lower environments a script would come in handy that would help us publish everything that got imported without reviewing the imported changes on an item per item basis.
The following is a pretty quick and simple script that will let you modify 3 parameters:
1. The root item from which we will start modifying the workflow state
2. The workflow state ID we want to use
3. The language of the items we want to target:
$rootItem = Get-Item -Path master:"START PATH" $language = "es" $workflowFinalState = "WORKFLOW STATE GUID" foreach ( $item in Get-ChildItem -Item $rootItem -Recurse -Language $language) { $item.Editing.BeginEdit(); $item.Fields["__Workflow state"].Value = $workflowFinalState $item.Editing.EndEdit(); Write-Host "$($item.FullPath) --> Updated" }