Get SharePoint Online workflows by using PowerShell CSOM
Get all SharePoint Online workflows by using PowerShell CSOM. Helpfull for workflow migrations to Flow or to just list all workflows

I have just published a blogpost to get the author of all published workflows on a site collection for SharePoint on-premises. The script in this blog will also list all your SharePoint Online workflows for a specific site collection using CSOM. You just need to edit the top variables and the script will do the rest for you.  You will be getting all SharePoint Online workflows for the URL you specify. You should run the below script for each site collection (or loop through all site collections) to retrieve all workflows on your environment. This information is helpful when planning to migrate to Microsoft Flow workflows or just list all workflows for a specific site.
You can simply add additional properties to the object like for example the last modified date. Please find the available properties at Microsoft

$url = "SharePoint Online URL"
$userName = "Site Collection Administrator"
$password = Read-Host "Please enter the password for $($userName)" -AsSecureString

#Create credential variable and enable 
$SPOCredentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($userName, $password)
$context = New-Object Microsoft.SharePoint.Client.ClientContext($url)
$context.Credentials = $SPOcredentials


Function Get-WorkflowAssociations($WorkflowDetails, $SPOCredentials, $Web){
    #Get Web information and subsites
    $context = New-Object Microsoft.SharePoint.Client.ClientContext($web)
    $context.Credentials = $SPOCredentials
    $web = $context.Web
        #check any subweb if present
        if ($web.Webs.Count -ne 0){
            foreach ($subweb in $web.Webs){
                Get-WorkflowAssociations -WorkflowDetails $WorkflowDetails -SPOCredentials $SPOCredentials -Web $subweb.url

        write-host $web.url

        foreach($list in $web.Lists) {     

            foreach($wfAssociation in $list.WorkflowAssociations) {
                if($ -notlike "*Previous Version*"){
                    $row=new-object PSObject
                    add-Member -inputObject $row -memberType NoteProperty -name "SiteURL" -Value $web.Url
                    add-Member -inputObject $row -memberType NoteProperty -name "ListTitle" -Value $list.Title
                    add-Member -inputObject $row -memberType NoteProperty -name "WorkflowName" -Value $wfAssociation.Name
        return $WorkflowDetails
        write-host "Error: $($_.Exception.Message)" -foregroundcolor green

$WorkflowDetails = Get-WorkflowAssociations -WorkflowDetails $WorkflowDetails -SPOCredentials $SPOCredentials -Web $url

Start the SharePoint Online Management Shell as administrator or use the new SharePoint Online module

Next copy and paste the script to this PowerShell window

You will first be asked to enter your credentials for the account you specified. Enter your password and press enter

The script will start to fill in the WorkflowDetails array which can be used to view, sort or export the data.
It will also output each site it finds just so you can view the progress.

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.