I’ve been making an attempt to handle workflows utilizing Powershell, specifically to have the ability to carry out bulk termination of workflows.
Nonetheless, I’m unable to initialise the WorkflowServicesManager in CSOM.
I had the Microsoft.SharePoint.Consumer.WorkflowServices.dll
in model 16, and the Sharepoint is on-premises 2016.
Right here is the code
# path to put in modules
$path = "C:Program FilesWindowsPowerShellModulesSharePointPnPPowerShellOnline3.12.1908.1"
# reference to wanted assemblies
Add-Kind -Path "$pathMicrosoft.SharePoint.Consumer.dll"
Add-Kind -Path "$pathMicrosoft.SharePoint.Consumer.Runtime.dll"
Add-Kind -Path "$pathMicrosoft.SharePoint.Consumer.Search.dll"
Add-Kind -Path "$pathOfficeDevPnP.Core.dll"
Add-Kind -Path "$pathMicrosoft.SharePoint.Consumer.WorkflowServices.dll"
$siteUrl = "https://mysite/websites/"
Join-PnPOnline $siteUrl -useWeblogin
$clientContext = Get-PnPContext
$rootWeb= $clientContext.Internet
$clientContext.Load($rootWeb)
$clientContext.Load($rootweb.Lists)
$clientContext.ExecuteQuery()
$webWFAssociations=$rootWeb.WorkflowAssociations
$clientContext.Load($webWFAssociations)
$clientContext.ExecuteQuery()
$WorkflowServicesManager = New-object Microsoft.SharePoint.Consumer.WorkflowServices.WorkflowServicesManager($clientContext,$rootWeb)
$WorkflowServicesManager.GetWorkflowInstanceService()
Right here is the error
New-object : Can not discover an overload for "WorkflowServicesManager" and the argument rely: "2".
At C:UsersMy UserDocumentsSharepointWorkflows.ps1:26 char:28
+ ... esManager = New-object Microsoft.SharePoint.Consumer.WorkflowServices.W ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [New-Object], MethodException
+ FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Instructions.NewObjectCommand