Cancel all running workflows at list

Sviatoslav Bulash -

#Add PS SharePoint snap in
asnp *sharepoint*
#Your ShareProint Site URL
$web = Get-SPWeb "http://HRIS/es";
$web.AllowUnsafeUpdates = $true;
#Your List Name
$list = $web.Lists["Performance Review"];
#Loop through all Items in List then loop through all Workflows on each List Items.
foreach ($listItem in $list.Items)
{
foreach ($workflow in $listItem.Workflows)
{
#Disregard Completed Workflows
if(($listItem.Workflows | where {$_.InternalState -ne "Completed"}) -ne $null)
{
#Cancel Workflows
[Microsoft.SharePoint.Workflow.SPWorkflowManager]::CancelWorkflow($workflow);
write-output "Workflow cancelled for : " $listItem.Title;
}
}
}
$web.Dispose();

Have more questions? Submit a request

Comments

Powered by Zendesk