Need powershell scripts to find the sites which had workflow enabled


  • Hi all,

    Accidentally I have cancelled all the  workflows in the sites. i want to revert it back. Is it possible to fetch the  sites in which the workflows had been enabled and enabling it back ?

    Does anyone have any scripts (Powershell ) to accomplish this.

    Please help us in resolving this issue

    Thanks in advance,


    Tuesday, February 28, 2012 5:55 AM


  • check the below code:

    to check for each list

    $siteURL="Site URl"
    $site=Get-SPSite $siteURL
    foreach($association in $associationColl)
    write-host $association.Name

    loop through all lists

    $site = Get-SPSite("your-site-url");
    $site.AllWebs | foreach { $_.Lists | foreach { $_.WorkflowAssociations | foreach { 
      write-host "Site:" $_.ParentWeb.Url ", List:" $_.ParentList.Title ", Workflow:" $_.Name
    } } }

    object model:

    SPSite site = new SPSite("SiteURL");
                foreach (SPWeb web in site.AllWebs)
                      SPFolder workFlowFolder = web.Folders["Workflows"];
                      SPFolderCollection folders = workFlowFolder.SubFolders;
                     foreach (SPFolder folder in folders)
                          if (folder.Name != "forms")

    MCTS,MCPD Sharepoint 2010. My Blog-

    If a post answers your question, please click "Mark As Answer" on that post and "Vote as Helpful

    Wednesday, February 29, 2012 5:10 PM