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 am writing a powershell script to find out all the In-Progress workflow instances in a site collection. Usually, the suggested way to do this is to find associated workflows to a list and check the status of the association. This saves from having to iterate through all list items.

BUT! I was able to find cases where I was running OOTB workflows (Feedback) on some list items - and they were never detected by the script. My only guess is that not all workflow instances necessarily have workflow association with the list. Could anyone shed some light into this for me please?

My PS pseudo-script:

 # For each site in site collection  
 # Get all Lists  
 # For each list  
 if (list.WorkflowAssociations.Count != 0)  
 foreach (SPWorkflowAssociation workflowAssociation in list.WorkflowAssociations)  
 {  
  # Get active workflows  
  ...  
 }  
share|improve this question
    
Could these worklfows be against the content type rather than the list itself ? –  Ian Apr 18 '12 at 7:06
add comment

2 Answers 2

up vote 1 down vote accepted

Check they're not content type workflows.

share|improve this answer
    
Thanks for the succinct answer. That helped. –  Tom Apr 18 '12 at 19:37
add comment

Reusable Workflows can be associated with:

  • List
  • Content Type
  • Content Type in list

so apart from $list.WorkflowAssociations you also needs to look at $list.ContentTypes | % {$_.WorkflowAssociations}

share|improve this answer
    
Thank you for the answer. This worked. –  Tom Apr 18 '12 at 19:36
    
Looks like I can only accept one answer :( –  Tom Apr 18 '12 at 19:36
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.