Hi Guys,
Is there a way I can list out the SharePoint 2010 workflows which have running instances in the list and libraries in SharePoint online.
Hi Guys,
Is there a way I can list out the SharePoint 2010 workflows which have running instances in the list and libraries in SharePoint online.
anonymous user
I'm checking how the things are going on about this issue. Whether the answer helps you?
You can accept the answer if it helps.
If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
You could try below script.
#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
Add-Type -Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.WorkflowServices.dll"
#Function to Get workflows in a site
Function Get-SPOWorkflowInventory($SiteURL, $CSVPath)
{
Try{
$WorkflowInventory = @()
#Setup the context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)
#Get the Web and its Subsites
$Web = $Ctx.Web
$Ctx.Load($Web)
$Ctx.Load($Web.Webs)
$Lists = $Web.Lists
$Ctx.Load($Lists)
$Ctx.ExecuteQuery()
Write-host -f Yellow "Searching Workflows in Site: $SiteURL"
#Loop through each list and get all workflows sharepoint online powershell
ForEach($List in $Lists)
{
#Get SharePoint 2010 Workflows Associated
$WorkflowAssociations = $List.WorkflowAssociations
$Ctx.Load($WorkflowAssociations)
$Ctx.ExecuteQuery()
ForEach($Association in $WorkflowAssociations | Where {$_.Name -notlike "*Previous Version*"})
{
$WorkflowData = New-Object PSObject
$WorkflowData | Add-Member NoteProperty WorkflowName($Association.Name)
$WorkflowData | Add-Member NoteProperty SiteURL($Web.Url)
$WorkflowData | Add-Member NoteProperty ListName($List.Title)
Write-host -f Green "`t Found Workflow '$($Association.Name)' in list '$($List.Title)'"
$WorkflowInventory+=$WorkflowData
}
}
#Export Workflow data to CSV File
If($WorkflowInventory) { $WorkflowInventory | Export-CSV -LiteralPath $CSVPath -NoTypeInformation -Append}
#Process Subsites
Foreach($Subweb in $Web.Webs)
{
Get-SPOWorkflowInventory -SiteURL $Subweb.url
}
}
Catch {
Write-host -f Red "Error:" $_.Exception.Message
}
}
#Set Parameters
$SiteURL="site collection URL "
$CSVPath = "your local drive"
#Remove the CSV file if exists
If(Test-Path $CSVPath) { Remove-Item $CSVPath}
#Get Credentials to connect
$Cred= Get-Credential
#Call the function to get workflow inventory
Get-SPOWorkflowInventory $SiteURL $CSVPath
Here're some references for you.
Get SharePoint Online workflows by using PowerShell CSOM
SharePoint Online get workflow inventory using PowerShell
If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
I could not find any Status property of the workflowassociation class. Could you please confirm this.
where is the updated script we cannot find any status property in that to know about running instances
Keep getting "Cannot validate argument on parameter 'LiteralPath'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again." on subsites. Thoughts? Using "C:\work\workflow" for parameter for $CSVPath, folder is there. Can manually pass it in using { $WorkflowInventory | Export-CSV -LiteralPath $CSVPath -NoTypeInformation -Append} but in script it fails.
It appears that this script identifies all the workflows in a list, but it does not identify the specific running instances.
Is there a way to identify the specific running instances?
5 people are following this question.