Reader Level:
ARTICLE

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

Posted by Vijai Anand Articles | SharePoint March 15, 2011
In this article we will be seeing how to get the workflows associated with a specific list using PowerShell in SharePoint 2010.
  • 0
  • 0
  • 12146

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.

    WorkFlow1.gif

Get the workflows associated with a specific list using C#

  • Open Visual Studio 2010.
  • Create Console Application.
  • Add the following Reference.
     
    • Microsoft.SharePoint.dll
       
  • Add the following Namespaces.
     
    • using Microsoft.SharePoint;
    • using Microsoft.SharePoint.Workflow;
  • Replace the code with the following.

class Program
    {
        static void Main(string[] args)
        {
            using (SPSite site = new SPSite("http://servername:1111/"))
            {
                using (SPWeb web = site.RootWeb)
                {
                    SPList list = web.Lists["Users"];                   
                    SPWorkflowManager manager = site.WorkflowManager;
                    SPWorkflowAssociationCollection associationColl = list.WorkflowAssociations;
                    foreach (SPWorkflowAssociation association in associationColl)
                    {
                        Console.WriteLine(association.Name.ToString());
                    }
                    Console.ReadLine();
                }
            }
        }
    }


WorkFlow2.gif

Get the workflows associated with a specific list using PowerShell

$siteURL="http://serverName:1111/"
$listName="Users"
$site=Get-SPSite $siteURL
$web=$site.RootWeb
$list=$web.Lists[$listName]
$wfManager=$site.WorkflowManager
$associationColl=$list.WorkflowAssociations
foreach($association in $associationColl)
{
write-host $association.Name
}
$web.Dispose()
$site.Dispose()

COMMENT USING

Trending up