Try this code
$siteURL="http://serverName/"
$listName="YourListName"
$site=Get-SPSite $siteURL
$web=$site.RootWeb
$list=$web.Lists[$listName]
$wfManager=$site.WorkflowManager
$associationColl=$list.WorkflowAssociations
foreach($association in $associationColl)
{
write-host $association.Name
}
$web.Dispose()
$site.Dispose()
Henrik,
Thanks i need a script to loop through all the lists in the farm
Thanks
Hi Lalit,
I'm not a powershell geek, there are many powershell communities, that can help you for sure. I gave you the syntax and someone else maybe can help you loop through the farm :)
Good luck.
Hi Lalit,
Beside Henrik’s command, here is some code about “How to list all the sub-sites and the site collections within a SharePoint web application using Windows Powershell”
- Marked as answer by Rock Wang MSFT Thursday, June 30, 2011 12:00 PM
Below is the powershell to get segregation of the workflows as well, like custom or SharePoint designer based or OOB
param ([boolean] $writeToFile = $true) #Get List of all workflows in farm with specified custom workflow activity 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:\directory\filename.txt)" } #Counter variables $webcount = 0 $listcount = 0 $associationcount = 0 #Get all webs Get-SPSite -Limit All | % {$webs += $_.Allwebs} if($webs.count -ge 1) { #Iterate through all webs foreach($web in $webs) { #Grab all lists in the current web $lists = $web.Lists foreach($list in $lists) { foreach($wf in $list.WorkflowAssociations) { #Ignore previous versions - Check for other languages too if($wf.Name -like "*Previous*") {continue} #Read Workflow instance XOML file write-host "`Iterating workflows: " $wf.Name -ForegroundColor "Yellow" [xml]$xmldocument = $wf.SoapXml if($xmldocument.FirstChild -ne $null) { $name = $xmldocument.FirstChild.GetAttribute("Name") $wfName = $name.Replace(" ", "%20") $webRelativeFolder = "Workflows/" + $wfName $xomlFileName = $wfName + ".xoml" $wfFolder = $wf.ParentWeb.GetFolder($webRelativeFolder) $xomlFile = $wfFolder.Files[$xomlFileName] if ($xomlFile.Exists) { $xomlStream = $xomlFile.OpenBinaryStream() $xmldocument.Load($xomlStream) $xomlStream.Close() Write-Host $wf.Name #Write below custom action dll reference if($xmldocument.OuterXml -like "*CustomDLLName*") { Add-Content -Path $outputPath -Value "$($web.url)+$($list.title)+$($wf.Name)+Custom" } else { Add-Content -Path $outputPath -Value "$($web.url)+$($list.title)+$($wf.Name)+OOB/Designer" } } else { Add-Content -Path $outputPath -Value "$($web.url)+$($list.title)+$($wf.Name)+OOB/Designer" } } else { Add-Content -Path $outputPath -Value "$($web.url)+$($list.title)+$($wf.Name)+OOB/Designer" } } } $webcount +=1 $web.Dispose() } #Show total counter for checked webs & lists Write-Host "Amount of webs checked:"$webcount $webcount = "0" } else { Write-Host "No webs retrieved" -ForegroundColor Red -BackgroundColor Black $webcount = "0" }