Try with the below scripts this should give you the accurate results for 2010 & 2013 workflows. If you miss any might be default reusable workflows which you can ignore them.
#Get SP 2010 Workflows
if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null)
{
Add-PSSnapin "Microsoft.SharePoint.PowerShell"
}
$results = @()
$siteColl = "http://sp/sites/dev"
$site = Get-SPSite -Identity $siteColl -Limit All
try
{
foreach ($myWeb in $site.AllWebs)
{
Write-Host "Looking in Web: " $myWeb.Url -ForegroundColor Red
foreach($list in $myWeb.Lists)
{
if ($list.WorkflowAssociations)
{
Write-Host $list.Title -ForegroundColor Blue
foreach ($wflowAssociation in $list.WorkflowAssociations)
{
$RowDetails = @{
"List Name" = $wflowAssociation.ParentList.Title
"Workflow Name" = $wflowAssociation.InternalName
"Running Instances" = $wflowAssociation.RunningInstances
"Created On" = $wflowAssociation.Created
"Modified On" = $wflowAssociation.Modified
"Parent Web" = $wflowAssociation.ParentWeb
"Task List" = $wflowAssociation.TaskListTitle
"History List" = $wflowAssociation.HistoryListTitle
}
$results += New-Object PSObject -Property $RowDetails
}
}
}
}
$myFileName = [Environment]::GetFolderPath("Desktop") + "\workflowList.csv"
$results | Select-Object "List Name", "Workflow Name", "Running Instances", "Created On","Modified On","Parent Web", "Task List","History List" | export-csv -Path $myFileName -NoTypeInformation
}
catch
{
$e = $_.Exception
$line = $_.InvocationInfo.ScriptLineNumber
$msg = $e.Message
Write-Host –ForegroundColor Red "Caught Exception: $e at $line"
Write-Host $msg
Write-Host "Something went wrong"
}
Write-Host " === === === === === Completed! === === === === === === == "
For SP 2013 workflows use the below script:
# Get SP 2013 workflows
if ((Get-PSSnapin 'Microsoft.SharePoint.PowerShell' -ErrorAction SilentlyContinue) -eq $null) {
Add-PSSnapin 'Microsoft.SharePoint.PowerShell'
}
CLS
$spAssignment = Start-SPAssignment
$outputFile = 'C:\Temp\2013Workflows.csv'
$output = '';
$wfResults = @();
$i = 0;
Write-Host 'Searching 2013 Workflows ....' -NoNewline;
$siteColl = "http://sp/sites/dev"
$site = Get-SPSite -Identity $siteColl -Limit All
# get the collection of webs
foreach($spWeb in $site.AllWebs) {
$wfm = New-object Microsoft.SharePoint.WorkflowServices.WorkflowServicesManager($spWeb)
$wfsService = $wfm.GetWorkflowSubscriptionService()
foreach ($spList in $spWeb.Lists) {
$subscriptions = $wfsService.EnumerateSubscriptionsByList($spList.ID)
foreach ($subscription in $subscriptions) {
#$subscriptions.name
#$subscriptions.PropertyDefinitions#._UIVersionString #_IsCurrentVersion
$i++
#excluding multiple version of the same workflow
if (($spWeb.Url + $spList.Title + $subscriptions.Name) -ne $output) {
$output = $spWeb.Url + $spList.Title + $subscription.Name
$wfID = $subscription.PropertyDefinitions["SharePointWorkflowContext.ActivationProperties.WebId"]
$wfResult = New-Object PSObject;
$wfResult | Add-Member -type NoteProperty -name 'URL' -value ($spWeb.URL);
$wfResult | Add-Member -type NoteProperty -name 'ListName' -value ($spList.Title);
$wfResult | Add-Member -type NoteProperty -name 'wfName' -value ($subscription.Name);
$wfResult | Add-Member -type NoteProperty -name 'wfID' -value ($wfID);
$wfResults += $wfResult;
}
if ($i -eq 10) {Write-Host '.' -NoNewline; $i = 0;}
}
}
}
$wfResults | Export-CSV $outputFile -Force -NoTypeInformation
Write-Host
Write-Host 'Script Completed'
Stop-SPAssignment $spAssignment
Thanks & Regards,