$WfServicesManager = New-Object Microsoft.SharePoint.Client.WorkflowServices.WorkflowServicesManager($ctx,$Web)
The error message: Cannot find an overload for "WorkflowServicesManager" and the argument count: "2"
Below is how I did the trouble shooting.
1. Compare the PowerShell environment version information.
$PSVersionTable shows everything is same in Console and ISE.2. Make sure the class exist in both environment.
$ClassName = "Microsoft.SharePoint.Client.WorkflowServices.WorkflowServicesManager"
if ($ClassName -as [type]) {
"$ClassName is already loaded"
}
else{
"$ClassName is not loaded"
}
Yes, the class is loaded.
3. Check how many relevant assemblies are loaded.
[appdomain]::currentdomain.getassemblies() | ?{$_.CodeBase -match "WorkflowServices"}
Here I noticed that ISE loaded a PnP assembly which also contains "Microsoft.SharePoint.Client.WorkflowServices.WorkflowServicesManager"
Obviously this is the root cause.
I think this is caused by old version PnP, so just removed/uninstalled these assemblies first.
Uninstall-Module SharePointPnPPowerShellOnline -AllVersions -Confirm
Then reinstalled the latest version.
nice!!! Worked!!!
ReplyDelete