Get a List of All Workflows in a Site Collection using PowerShell

I’ve faced a situation where I needed to figure out what workflows had been created by my clients on a given Site Collection. A user had created a Workflow he remembered naming “Mike’s custom approval Workflow” but couldn’t remember where (on what list) he had created it. I’ve created the following PowerShell script to iterate through all Webs of a given site collection and to retrieve the name of all workflows that have been created on lists. The script expects the user to enter the URL for the root web of the site collection, then iterates through all of its webs, then through all lists, and finally loops through all Workflows associations on these lists. If it finds any workflows, thne it prints its name on screen preceeded by the name of the list on which it has been created.

$siteURL = Read-Host “URL of the Site Collection”
$site = Get-SPSite($siteURL)
foreach($web in $site.AllWebs)
foreach($spList in $web.Lists)
foreach($wfAssociation in $spList.WorkflowAssociations)
Write-Host “{“$wfAssociation.ParentList.Title”} -” $wfAssociation.Name -BackgroundColor Green -ForegroundColor Black

Leave a Reply

Your email address will not be published. Required fields are marked *