Is there a powershell script or service out there that gives you a list of all workflow statuses? Primarily we are looking for a way to get a list of all current suspended workflows.


Here is the script for receiving statuses of all workflow statuses. It need to be tweeked to only show only suspended, which I will post later. As of right now though it is a working turn key script. I hope you find it useful!

#Import SharePoint Online Management Shell
Import-Module Microsoft.Online.SharePoint.Powershell -ErrorAction SilentlyContinue

Add-PSSnapIn Microsoft.SharePoint.PowerShell  -ErrorAction SilentlyContinue

#region Input Variables 

$SiteUrl = "https://xxx.sharepoint.com" #Replace the URL

$UserName = Read-Host -Prompt "Enter User Name"
$SecurePassword = Read-Host -Prompt "Enter password" -AsSecureString

$cred = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $UserName, $SecurePassword


#region Connect to SharePoint Online tenant and Create Context using CSOM

    #region Load SharePoint Client Assemblies

    Add-Type -Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"
    Add-Type -Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
    Add-Type -Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.WorkflowServices.dll"


    #region connect/authenticate to SharePoint Online and get ClientContext object..    

    $clientContext = New-Object Microsoft.SharePoint.Client.ClientContext($SiteUrl) 
    $credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName, $SecurePassword) 
    $clientContext.Credentials = $credentials

    Write-Host "Connected to SharePoint Online site: " $SiteUrl -ForegroundColor Green
    Write-Host ""


    $SPOConnectionException = $_.Exception.Message
    Write-Host ""
    Write-Host "Error:" $SPOConnectionException -ForegroundColor Red
    Write-Host ""


if (!$clientContext.ServerObjectIsNull.Value) 
        $web = $clientContext.Web
        $lists = $web.Lists

        $workflowServicesManager = New-Object Microsoft.SharePoint.Client.WorkflowServices.WorkflowServicesManager($clientContext, $web);
        $workflowSubscriptionService = $workflowServicesManager.GetWorkflowSubscriptionService();
        $workflowInstanceSevice = $workflowServicesManager.GetWorkflowInstanceService();

        Write-Host ""
        Write-Host "Exporting Lists" -ForegroundColor Green
        Write-Host ""

        foreach ($list in $lists)         
            $workflowSubscriptions = $workflowSubscriptionService.EnumerateSubscriptionsByList($list.Id);
            foreach($workflowSubscription in $workflowSubscriptions)
                Write-Host "**************************************************************************************"
                Write-Host "List -"$list.Title " Workflow - "$workflowSubscription.Name -ForegroundColor Green
                Write-Host "***************************************************************************************"
                Write-Host ""

                $camlQuery = New-Object Microsoft.SharePoint.Client.CamlQuery
                $camlQuery.ViewXml = "<View> <ViewFields><FieldRef Name='Title' /></ViewFields></View>";
                $listItems = $list.GetItems($camlQuery);

                foreach($listItem in $listItems)
                    $workflowInstanceCollection = $workflowInstanceSevice.EnumerateInstancesForListItem($list.Id, $listItem.Id);
                    foreach ($workflowInstance in $workflowInstanceCollection)
                       Write-Host "List Item Title:"$listItem["Title"] 
                       Write-Host "Workflow Status:"$workflowInstance.Status 
                       Write-Host "Last Updated:"$workflowInstance.LastUpdated
                       Write-Host ""
                Write-Host ""



  • try this link codeproject.com/Articles/607127/… from this use Enumerate workflow definitions of a site. But you have to tweak as per your requirment
    – Waqas Sarwar MVP
    Commented Oct 30, 2014 at 20:40
  • Ill take a look. Thank you! Could you submit this as a possible answer so I can mark it as correct for future people with this issue? Commented Oct 30, 2014 at 21:41

1 Answer 1


Please try the below code from Using SharePoint 2013 Workflow Services JS API. You may have to tweak it according to your requirement.

(function () {

    // Getting client context and loading the current web
    var context = SP.ClientContext.get_current();
    var web = context.get_web();

    // Workflow Services API entry point - WorkflowServiceManager object
    var servicesManager = SP.WorkflowServices.WorkflowServicesManager.newObject(context, web);

    var workflowDefinitions = servicesManager.getWorkflowDeploymentService().enumerateDefinitions(false);

    context.executeQueryAsync(function (sender, args) {

        // enumerateDefinition returns ClientCollection object
        var definitionsEnum = workflowDefinitions.getEnumerator();

        var empty = true;

        console.log('Site ' + web.get_url() + ':');

        // Going through the definitions
        while (definitionsEnum.moveNext()) {

            var def = definitionsEnum.get_current();

            // Displaying information about this definition - DisplayName and Id
            console.log(def.get_displayName() + " (id: " + def.get_id() + ")");

            empty = false;


        if (empty) {
           console.log('No 2013 workflows found.');

    }, errFunc);

    // Error handling
    function errFunc(sender, args) {
        alert("Error occured! " + args.get_message());

  • Thanks for adding this. Ill be adding the script I come up with after I fiddle around with it. Commented Oct 30, 2014 at 21:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.