0

How to clean-up or remove the orphaned workflows in a site collection?

I have created a SPD 2010 reusable workflow and deployed in SP 2013 environment. But for some of the sub sites and some document libraries I am unable to trigger this workflow.

So I want to delete the existing workflow instance which is associated with the content types from this site collection.

Is there any PowerShell script to do this job?

0

1 Answer 1

0

You can use below script

$web = Get-SPWeb http://weburl
$list = $web.Lists["Document Library"]

$ct = $list.ContentTypes["ContentTypeName"]

foreach($association in $ct.WorkflowAssociations)
{
    write-host $association.name

    $ct.RemoveWorkflowAssociation($association)
}
2
  • Thanks for the reply.But its not completely removed from my site, though its not seen when I check in the workflow settings of my document library. But I am able to see the "deleted" workflow instances when I went through the SP D and clicked on the content types, and in the workflows section. It has become the orphaned workflow instance now. Commented May 1, 2015 at 14:03
  • Try closing and reopening SPD Commented May 1, 2015 at 14:05

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.