Asked by:
Get all SharePoint Designer 2013 Workflows using PowerShell

Question
-
Hello,
I would like to get all SharePoint designer workflows using PowerShell. We are using SharePoint 2013 but we have so many 2010 designer workflows as well. I want to get a list of all 2010 and 2013 workflows in SharePoint 2013 using PowerShell along with the site link and workflow name. Can anyone please provide me the script?
Thanks,
Cherry
Monday, January 13, 2020 8:39 PM
All replies
-
FYI
Justin Liu Office Apps & Services MVP, MCSE
Senior Software Engineer
Learn Microsoft 365 from Microsoft DOCs now!
Please Vote and Mark as Answer if it helps you.Tuesday, January 14, 2020 1:15 AM -
Hi Cherry,
We could get the SharePoint 2010 platform workflow from below PowerShell:
param ([boolean] $writeToFile = $true) #List all 2010 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 += $($listassociation.name) } $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 $web.Dispose() } #Show total counter for checked webs & lists Write-Host "Amount of webs checked:"$webcount Write-Host "Amount of lists checked:"$listcount $webcount = "0" } else { Write-Host "No webs retrieved, please check your permissions" -ForegroundColor Red -BackgroundColor Black $webcount = "0" }
Reference: Get all workflows in all sites and lists
However, 2013 Workflows are registered as subscriptions to Workflow Manager, that is not technically a part of SharePoint 2013 farm but a standalone component.
Please refer following PowerShell to enumerate throughout all Web Applications and generates the list of all 2013 Workflows in the SharePoint 2013 Farm and export it as a CSV file in your computer:
if ((Get-PSSnapin 'Microsoft.SharePoint.PowerShell' -ErrorAction SilentlyContinue) -eq $null) { Add-PSSnapin 'Microsoft.SharePoint.PowerShell' } CLS $spAssignment = Start-SPAssignment $outputFile = 'D:\Temp\2013Workflows.csv'(Please note you need to specify the export file path in your computer) $output = ''; $wfResults = @(); $i = 0; Write-Host 'Searching 2013 Workflows ....' -NoNewline; # Get All Web Applications $WebApps = Get-SPWebApplication foreach($webApp in $WebApps) { # Get All Site Collection foreach ($spSite in $webApp.Sites) { # get the collection of webs foreach($spWeb in $spSite.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
Reference: SharePoint 2013 – List of 2013 Workflows
Please Note: Since the web site is not hosted by Microsoft, the link may change without notice. Microsoft does not guarantee the accuracy of this information.
Best regards,
Julie
Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.
SharePoint Server 2019 has been released, you can click here to download it.
Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.- Proposed as answer by Chelsea WuMicrosoft contingent staff Wednesday, January 15, 2020 8:41 AM
Tuesday, January 14, 2020 7:13 AM -
Hi Cherry,
I’m checking how the things are going on about this issue. Whether the post helps you?
Please feel free to reply if there is any update.
Best regards,
Julie
Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.
SharePoint Server 2019 has been released, you can click here to download it.
Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.Monday, January 20, 2020 2:49 AM -
Thank you all for your replies. I will try this week and let you know. Thanks.Tuesday, January 21, 2020 4:30 PM
-
Hi Cherry,
Looking forward to your reply if there is any update.
Best regards,
Julie
Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.
SharePoint Server 2019 has been released, you can click here to download it.
Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.Wednesday, January 22, 2020 3:11 AM -
Hi Cherry,
Do you have any progress on this issue?
Please remember to update this thread if you need further assistance.
Best regards,
Julie
Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.
SharePoint Server 2019 has been released, you can click here to download it.
Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.Monday, January 27, 2020 1:18 AM -
Hi Julie,
I have tried to run the 2010 workflows, looks like it is talking very time. My script is running for the past 1 hr. This is unusual and finally I received an error. I was able to execute the 2013 script.
Thanks for the follow up.
- Edited by CherryP Monday, January 27, 2020 6:35 PM
Monday, January 27, 2020 6:25 PM -
Hi Cherry,
Please provide a screenshot of the error message for further investigation.
Best regards,
Julie
Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.
SharePoint Server 2019 has been released, you can click here to download it.
Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.Thursday, January 30, 2020 5:54 AM -
Hi @Justin Liu
I can able to read xaml file for the SP2010 workflow using below code. But its not working for the SP2013 workflows. Is there any other way to read the xml file. The reason why i need the xml is to get the step details inside the workflow.
Function GetXOMLFromWorkflowInstance($wfa)
{
[xml]$xmldocument = $wfa.SoapXml
$name = $xmldocument.FirstChild.GetAttribute("Name")
$wfName = $name.Replace(" ", "%20")
$global:workflowName= $name
#$wfName="ManagerNotification"
$webRelativeFolder = "Workflows/" + $wfName
$xomlFileName = $wfName + ".xoml"
$wfFolder = $wfa.ParentWeb.GetFolder($webRelativeFolder)
$xomlFile = $wfFolder.Files[$xomlFileName]
if ($xomlFile.Exists)
{
$xomlStream = $xomlFile.OpenBinaryStream()
$xmldocument.Load($xomlStream)
$xomlStream.Close()
return $xmldocument.OuterXml
}
return $xomlFileName
}Please help me out...
- Edited by Kanagaraj Neelamegan Thursday, July 23, 2020 11:45 AM
Thursday, July 23, 2020 11:44 AM