top of page

How to get the workflows associated with a specific list using PowerShell in SharePoint 2010

In this article we will be seeing how to get the workflows associated with a specific list using PowerShell in SharePoint 2010.

In this article

  • Get the workflows associated with a specific list using C#.

  • Get the workflows associated with a specific list using PowerShell.


Get the workflows associated with a specific list using C#

a. Open Visual Studio 2010.

b. Create Console Application.

c. Add the following Reference. i) Microsoft.SharePoint.dll d. Add the following Namespaces. i) using Microsoft.SharePoint;

ii) using Microsoft.SharePoint.Workflow;

e. Replace the code with the following.

  1. class Program   

  2. {

  3. static void Main(string[] args)       

  4. {

  5. using (SPSite site = new SPSite("http://servername:1111/"))           

  6. {

  7. using (SPWeb web = site.RootWeb)               

  8. {

  9. SPList list = web.Lists["Users"];                   

  10. SPWorkflowManager manager = site.WorkflowManager;

  11. SPWorkflowAssociationCollection associationColl = list.WorkflowAssociations;

  12. foreach (SPWorkflowAssociation association in associationColl)                   

  13. {

  14. Console.WriteLine(association.Name.ToString());                   

  15. }

  16. Console.ReadLine();               

  17. }           

  18. }       

  19. }   

  20. }





Get the workflows associated with a specific list using PowerShell

  1. $siteURL="http://serverName:1111/"

  2. $listName="Users"

  3. $site=Get-SPSite $siteURL

  4. $web=$site.RootWeb

  5. $list=$web.Lists[$listName]

  6. $wfManager=$site.WorkflowManager

  7. $associationColl=$list.WorkflowAssociations

  8. foreach($association in $associationColl)

  9. {

  10. write-host $association.Name

  11. }

  12. $web.Dispose()

  13. $site.Dispose()

0 comments
bottom of page