SharePoint 2007 – Content Audit: Print All Workflows

In this post I would discuss the PowerShell script to query all workflows in SharePoint farm. You may have deployed custom Workflow solutions like custom activities available on CodePlex or built workflows in SharePoint Designer or Visual Studio. It’s important to understand what sort of workflows you have running in your environment & their upgradability to properly plan an upgrade project.

There is no way in SharePoint to say whether a workflow has been built on SharePoint Designer or Visual Studio. Thus, we would use the SPList Workflow Associations property to get all Workflows & then filter-out the ones we don’t care like standard approval workflows.

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")

# Print all workflows in Web Application
function PrintWorkflowDetails(){

    $rootSite = new-object Microsoft.SharePoint.SPSite("");
    $webApp = $rootSite.WebApplication;

    foreach($site in $webApp.Sites){
        foreach($web in $site.AllWebs){
            foreach($list in $web.Lists){
                foreach($wkfAssociation in $list.WorkflowAssociations){
                    
                    # Include only current versions
                    # Exclude all built-in approval workflows
                    if($wkfAssociation.Name.contains("Previous") -or $wkfAssociation.Name.Contains("Approval") -or $wkfAssociation.Name.contains("Disposition") ){
                    
                    }else{
                        $data = @{
                                "Site URL" = $wkfAssociation.ParentSite.Url
                                "Web URL" = $wkfAssociation.ParentWeb.Url
                                "List" = $list.Title
                                "Workflow" =  $wkfAssociation.Name
                        }
                        New-Object PSOBJECT -Property $data
                    }
                }
            }
            $web.Dispose();    
        }
        $site.Dispose();
    }
    $rootSite.Dispose();

}

PrintWorkflowDetails | OUT-GRIDVIEW 
#PrintWorkflowDetails | Select-Object "Site URL" , "Web URL", "List", "Workflow" | Export-Csv -NoTypeInformation -Path "\WorkflowInventory.csv"


Comments

Popular posts from this blog

Hybrid Apps using Cordova/PhoneGap: Ditch JQuery Mobile

SharePoint 2013 Search Service Activation Error

VMWare Workstation - Assign a static IP address