Steps to list out All workflows presented in SharePoint 2007 Site Collection and SharePoint 2013


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 google I found any very good script by Jeff Holliday which worked very well.


Also read:
Get SharePoint list created date using PowerShell

How to cancel all workflows having Suspended state in SharePoint 2013?

Download a wsp file from SharePoint using PowerShell

Below is the script:

#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

SharePoint 2013:
The below script will work in SharePoint 2013.

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



Hope this will be helpful.

Check out Best Alternative to InfoPath -> Try Now

You May Also like the Following SharePoint Online Tutorials:

About Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site SharePointSky.com

View all posts by Bijay Kumar →