Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I've been developing some List Workflows on SPD 2010 and using the publish button to push them to the webserver. Everytime I publish a new version, the previous one gets labeled 'Previous Versions'.

Now, when I go to the Workflow Settings for that list, I can find at least a hundred workflows, most of them Previous Versions. If I check the workflows tab on SPD 2010 I only find the current version of my workflows.

Is there a way to remove all those previous versions from the Server?

share|improve this question
    
I have not worked with workflows in a long time but I remember vaguely. You should be able to remove the previous versions from the workflow settings page. –  Nitin Rastogi Dec 26 '11 at 6:29
    
Is there a way to do this via UI instead of powershell? –  Emon Jan 8 at 21:58
add comment

1 Answer

up vote 3 down vote accepted

It should be possible using Powershell.

  1. You need to open the site and get the list.
  2. Iterate through list workflow association and remove whichever is not required.
  3. Sample code might look like this -

    $web = Get-SPWeb 'Web URL'

    $listToCancel = "List Name"

    $list = $web.Lists[$listToCancel]

    $tempList = New-Object "System.Collection.Generic.List``1[System.Object]"

    $wfToKeep = "Workflowname"

    foreach ($wf in $list.WorkFlowAssociations) {

    if ($wf.Name -ne $wfToKeep) { $tempList.Add($wf); }

    }

    foreach ($wf in $tempList){ $list.RemoveWorkflowAssociation($wf); }

share|improve this answer
    
Excellent script. This helped me. –  Kannan Sep 16 '12 at 8:15
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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