SharePoint PowerShell - Get Workflows

Get all Workflows in a SharePoint Site


param ([boolean] $writeToFile = $true)
#List all workflows in farm
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue #If boolean is set to true, you can specify an outputlocation, to save to textfile.

if($writeToFile -eq $true)
$outputPath = Read-Host "Outputpath (e.g. C:directoryfilename.txt)"
#Counter variables
$webcount = 0
$listcount = 0
$associationcount = 0

#Grab all webs
Get-SPSite -Limit All | % {$webs += $_.Allwebs}
if($webs.count -ge 1)
foreach($web in $webs)
#Grab all lists in the current web
$lists = $web.Lists
foreach($list in $lists)
$associations = @()
#Get all workflows that are associated with the current list
foreach($listassociation in $list.WorkflowAssociations)
$associations += $($
$listcount +=1
if($associations.count -ge 1)
Write-Host "Website"$web.url -ForegroundColor Green
Write-Host "  List:"$list.Title -ForegroundColor Yellow
foreach($association in $associations){Write-Host "   -"$association}

if($WriteToFile -eq $true)
Add-Content -Path $outputPath -Value "Website $($web.url)"
Add-Content -Path $outputPath -Value "  List: $($list.Title)"
foreach($association in $associations){Add-Content -Path $outputPath -Value "   -$association"}
Add-Content -Path $outputPath -Value "`n"
$webcount +=1
#Show total counter for checked webs & lists
Write-Host "Amount of webs checked:"$webcount
Write-Host "Amount of lists checked:"$listcount
$webcount = "0"
Write-Host "No webs retrieved, please check your permissions" -ForegroundColor Red -BackgroundColor Black
$webcount = "0"

Share on Google Plus

About Tom DeMeulenaere

Highly accomplished information technology professional with extensive knowledge in System Center Configuration Manager, Windows Server, SharePoint, and Office 365.
    Blogger Comment


Post a Comment

Note: Only a member of this blog may post a comment.