I need to remove from a SharePoint site collection all Workflows named "ToDoWF". There are over 200 libraries therefore removing manually will be a large task. The workflows are based on SharePoint 2013 using SharePoint Designer 2013. I found the below script however it is based on SharePoint 2010 workflows. Any guidance will be appreciated on how to modify it for SharePoint Designer 2013 workflows. FYI previous developer did not use reusable workflows therefore need to remove from each library.
$SPSite = Get-SPSite(https://xxxxx)
$siteAddress
if($SPSite -ne $null)
{
# Get the root website
$Web = $SPSite.OpenWeb();
# Get the list to which we wanted to associate the workflow
$SPList =$Web.Lists[“StuffToDo”];
$workflowAssociation = $SPList.WorkflowAssociations.GetAssociationByName(“ToDoWF”, [System.Threading.Thread]::CurrentThread.CurrentCulture);
if($workflowAssociation -ne $null)
{
# Remove workflow association to list
$SPList.RemoveWorkflowAssociation($workflowAssociation);
$SPList.Update();
Write-Host “Workflow association removed Successfully.” -foreground color “Green”
}
else
{
Write-Host “Workflow association could not be found.” -foregroundcolor “Yellow”
}
}
Evy