Get SharePoint Online (Office 365 Enterprise E3) Subscription for your Business NOW

Get all workflows from all site collections using server object model in SharePoint 2013

In this post, we will discuss how to get all the workflows from site collection using the server object model in SharePoint 2013. Here we have written a console application which gave us the workflows presented in all the site collections.

You may also read:
Get Profile picture url from User Information List using SharePoint 2013 server object model

How to get all items from a particular List View in SharePoint CSOM Javascript?

Install workflow manager sharepoint 2013 step by step

Below is the code:

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;
using Microsoft.SharePoint.Workflow;
using System.IO;
namespace GetAllWFs
class Program
static void Main(string[] args)
string site;
Console.WriteLine(“Enter the Web Application URL:”);
site = Console.ReadLine();

string date = string.Format(“{0:dd-MM-yyyy}”, DateTime.Now);
string path = “WorkFlowList_” + date + “.xls”;
StreamWriter sw = File.CreateText(path);
SPSite tmpRoot = new SPSite(site);
SPSiteCollection tmpRootColl = tmpRoot.WebApplication.Sites;
int count = 0;
foreach (SPSite tmpSite in tmpRootColl)

foreach (SPWeb tmpWeb in tmpSite.AllWebs)
foreach (SPList tmpList in tmpWeb.Lists)
SPWorkflowManager manager = tmpSite.WorkflowManager;
SPWorkflowAssociationCollection associationColl = tmpList.WorkflowAssociations;
foreach (SPWorkflowAssociation association in associationColl)
sw.AutoFlush = true;
sw.Write(association.Name.ToString() + “\t”);

Console.WriteLine(count + ” work flows exported to excel :E:\\Bijay\\” + path);

It will put in excel.

Check out Best Alternative to InfoPath -> Try Now

EnjoySharePoint YouTube Channel

You May Also like the Following SharePoint 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

View all posts by Bijay Kumar →