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?

marked as duplicate by Eric Alexander May 1 '15 at 12:22

This question was marked as an exact duplicate of an existing question.

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)
}
  • 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. – SaMolPP May 1 '15 at 14:03
  • Try closing and reopening SPD – Amal Hashim May 1 '15 at 14:05

Not the answer you're looking for? Browse other questions tagged or ask your own question.