Privacy Info

Friday, December 2, 2022

Sitecore PowerShell Script - Remove item from Workflow

We came across scenario where we need to remove multiple items from workflow. If items would be less then there would not be any issue but items to be removed were large in number. After some research we decided to create PowerShell to solve this problem. We came up with below script which we ran across folders recursively and remove the items from workflow. To remove items from workflow we need to make Workflow and Workflow State field as blank.

Script

$folderPath = "master:\sitecore\content\Home\TestFolder"

$items = Get-ChildItem -Path $folderPath -Recurse 

foreach($item in $items)
{
	$item.Editing.BeginEdit()
	$item.Fields["__Workflow"].Value = ""
	$item.Fields["__Workflow state"].Value = ""
	$item.Editing.EndEdit() | Out-Null
	Write-Host "Item $($item.name) removed from Workflow"	
}	

Hope you find this blog helpful 😀


Article Referred 

https://www.logicalfeed.com/posts/1194/sitecore-powershell-script-to-remove-update-workflows

Sitecore PowerShell Script - Remove item from Workflow

We came across scenario where we need to remove multiple items from workflow. If items would be less then there would not be any issue but i...