Powershell script to find all list workflows in a farm
Does any body know of any way or script to list down all the list workflows in a sharepoint farm.
June 19th, 2011 6:28pm

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()

Free Windows Admin Tool Kit Click here and download it now
June 19th, 2011 8:48pm

Henrik,

Thanks i need a script to loop through all the lists in the farm

 

Thanks

 

June 20th, 2011 3:45pm

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.

Free Windows Admin Tool Kit Click here and download it now
June 20th, 2011 6:17pm

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”

http://blogs.msdn.com/b/vijay/archive/2009/10/01/how-to-list-all-the-sub-sites-and-the-site-collections-within-a-sharepoint-web-application-using-windows-powershell.aspx

June 23rd, 2011 6:41am

Is the $wfManager=$site.WorkflowManager line required?
Free Windows Admin Tool Kit Click here and download it now
April 24th, 2013 4:23pm

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"
}

July 21st, 2015 10:15am

Would be easier to just query SharePoint for ALL lists and then do a foreach on that to check for workflows... Just my 2cents
Free Windows Admin Tool Kit Click here and download it now
July 22nd, 2015 2:53am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics