List out all workflows presented in SharePoint Site Collection using PowerShell

This SharePoint tutorial explains, how to list out all workflows presented in a SharePoint site collection using PowerShell.

Recently while working in a MOSS 2007 to SharePoint 2013 migration project we need to check how many workflows are there in MOSS 2007 and the corresponding attached lists also. So after a google, I found any very good script by Jeff Holliday which worked very well.

List out all workflows presented in SharePoint Site Collection using PowerShell

Below is the script to list out all workflows presented in a SharePoint site collection using PowerShell. First, we will see how to get all the workflows presented in MOSS 2007 site collection using PowerShell.

#Load SharePoint 2007 Assemblies
[System.Reflection.Assembly]::Load("Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c") | out-null

$siteurl="http://SiteColURL/"
$site=new-object Microsoft.SharePoint.SPSite($siteurl)

#Initialize Workflow Count variable
$workflowcount = 0

#Foreach loop to loop through all webs, and lists with workflow associations, and exclude workflows that have previous versions and write findings to .csv file.

function Get-Workflows()
{
foreach($web in $site.AllWebs)
{
foreach($list in $web.Lists)
{
foreach($wf in $list.WorkflowAssociations)
{
if ($wf.Name -notlike "*Previous Version*")
{
$hash = @{"[URL]"=$web.Url;"[List Name]"=$list.Title;"[Workflow]"=$wf.Name}
New-Object PSObject -Property $hash | Sort-Object

}
}
}
}
}

foreach($web in $site.AllWebs)
{
foreach($list in $web.Lists)
{
foreach($wf in $list.WorkflowAssociations)
{
if ($wf.Name -notlike "*Previous Version*")
{
$workflowcount += 1
}
}
}
}

Get-Workflows | Export-csv D:\Biju\workflows.csv
"Workflow Count " + $workflowcount >> D:\Biju\workflows.csv

$site.Dispose()

[URL] [List Name] [Workflow] http://URL Tasks MyTestApp

Workflow Count 1

List all workflows from SharePoint 2013 site collection using PowerShell

The below PowerShell script is to list all workflows from SharePoint 2013/2016 site collection using PowerShell.

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

You may like following SharePoint tutorials:

In this tutorial, we learned how to list all workflows from the SharePoint site collection using PowerShell. The same PowerShell script we can use to list all workflows from SharePoint 2010/2013/2016 site collections.

Donwload Hub site pdf

Download SharePoint Online Tutorial PDF FREE!

Get update on Webinars, video tutorials, training courses etc.

>