I am running the below PowerShell script to get the all workflow in a given web application:

#For SharePoint 2007 Compatibility
Function global:Get-SPWebApplication($WebAppURL)
 return [Microsoft.SharePoint.Administration.SPWebApplication]::Lookup($WebAppURL)
#Function to Get the workflow inventory for the entire web application
function Get-WorkflowInventory([string] $WebAppURL)
    #Get the Web Application URL
    $WebApp = Get-SPWebApplication $WebAppURL 
    #Iterate through each site collection
    foreach ($Site in $WebApp.Sites)
                #Loop through each site    
                foreach ($Web in $Site.AllWebs)
                    #Loop through each list
                    foreach ($List in $Web.Lists)
                         # Leave hidden Lists and Libraries
                         if($List.Hidden -eq $false)
                            foreach ($WorkflowAssociation in $List.WorkflowAssociations)
                                #Leave the "Previous Versions"
                                if($WorkflowAssociation.Name.Contains("Previous Version") -eq $false)
                                       $data = @{
                                        "Site" = $Site.Rootweb.Title
                                        "Web" = $Web.Title
                                        "Web URL" = $Web.Url
                                        "List Name" = $List.Title
                                        "List URL" =  $Web.Url+"/"+$List.RootFolder.Url
                                        "Workflow Name" = $WorkflowAssociation.Name
                                        "Running Instances" = $WorkflowAssociation.RunningInstances
                                        #Create a object
                                        New-Object PSObject -Property $data

#call the function
Get-WorkflowInventory "http://sharepoint.crescent.com" | Export-Csv -NoTypeInformation -Path D:\Reports\WorkflowInventory.csv
write-host "Workflows Inventory report has been generated successfully!"

The above script is working fine which gives the output with the below columns:

  • Site
  • Web
  • Web URL
  • List Name
  • List URL
  • Workflow Name
  • Running Instances

In the above report, I want to include the workflow last run/execution time - how can we do that as we don't see any property with the last run/execution time in $WorkflowAssociation?

1 Answer 1


We have LastUpdated property in workflowInstance class which you can have a try.

Examples: https://gallery.technet.microsoft.com/office/How-get-the-workflow-7d00eed9

Get the SharePoint 2013 workflow execution status for all the workflows in a Site

  • Hi - Thanks for your reply - I understand the LastUpdated property part of the workflow instance which runs on item level - so, it is difficult to scan thru all items in the SharePoint web application as we have lakhs of items. Actually, we wanted to scan our SP 2016 farm to collect all workflows and then decide which workflow is in used or not used at all - so, do we have any tool to do this? I know we have a SharePoint modernization tool, but that runs in SP online not in SP on-premise.
    – SP 2022
    Nov 12, 2020 at 7:55

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.