Hi @sns,
This script iterates through all site collections-sites-List objects to fetch workflow data such as: Workflow Name, Running instances. I'm afraid the users who published the workflow cannot be fetched.
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
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 an object
New-Object PSObject -Property $data
}
}
}
}
$Web.Dispose()
}
$Site.Dispose()
}
}
#call the function
Get-WorkflowInventory "https://sharepoint.crescent.com" | Export-Csv -NoTypeInformation -Path D:\Reports\WorkflowInventory.csv
write-host "Workflows Inventory report has been generated successfully!"
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.