none
Need powershell scripts to find the sites which had workflow enabled

    Question

  • 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,

    KAV

    Tuesday, February 28, 2012 5:55 AM

Answers

  • check the below code:

    to check for each list

    $siteURL="Site URl"
    $listName="YourListName"
    $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()

    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- http://sharepoint-journey.com


    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