Powershell Script to Find Workflow Running Instances in SharePoint Site

  1. #List all workflows Running Instances in SPSite  
  2. Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue  
  3.   
  4. $siteURL = read-host "Enter the site URL"  
  5. $web=Get-SPWeb $siteURL  
  6. $lists=$web.Lists  
  7. $wf=foreach ($list in $lists)  
  8. {  
  9.    $list.WorkflowAssociations | where {$_.RunningInstances -gt 0}  
  10. }  
  11. if($wf)  
  12. {  
  13.    write-host "Workflow running instance found" -fore green  
  14.    $wf | select Name,ParentList,RunningInstances | Format-List;  
  15. }  
  16. else  
  17. {  
  18.    write-host  "No workflow running instance found" -fore cyan  
  19. }  
  20. $web.Dispose();