List all Workflows in a SiteCollection
 We had business requirement to display a
list of all workflows in a Site collection.There are
different approaches to view list of workflows in a sitecollection for a list
or document library.
Go to the
document library or list under Library Settings/List Settings user can view
  with 
- Sharepoint UI ,
 - Powershell
 
If
you have a collection with few document librarys or lists you can manually
navigate to each document library or list and check for workflows in SharePoint
UI 
Library
Settings/List Settings -> Workflow Settings ->
You can see in the above there are no workflows associated with the list.
Using PowerShell, to Export all the workflow in a site collection to CSV
PowerShell script to find out list of all workflows in a site collection is the best way to find.
SharePoint has a class called "WorkflowAssociation : "
contains members that return custom information about that 
workflow's a 's association with the specific list or content 
type.
Cls
Add-PSSnapin "Microsoft.Sharepoint.Powershell"
$site=
Get-SPSite -Identity  "http://test.devsites/sites/wfs"
function DisplayWorkflows()
{
   foreach($subwebs in $site.AllWebs
)
   {
     $ls= $subwebs.Lists;
    foreach($lists in $ls )
    {
    $workflows= $lists.WorkflowAssociations;
    foreach($wf in $workflows)
    {
    if($wf.Name -notlike "*Previous
Version*")
        {
        $output
= @{"[URL]"=$web.Url;"[ListName]"=$lists.Title;"[Workflow
Title]"=$wf.Name }
        New-Object
PSObject -Property
$output |
Sort-Object;
         }
     }
    }
    }
  }
    DisplayWorkflows
| Export-Csv  C:\ListofWorkflows.csv 

No comments:
Post a Comment