While using Invoking PowerShell activity, it is not possible to cast object of type 'Microsoft.SharePoint.Client.File' to type 'System.Management.Automation.PSObject' . What should be performed?
Issue Description:
Using "Invoke Power Shell" activity, a power shell script is executed which uploads files to SharePoint online. On this script execution, it throws "System.InvalidCastException" exception as below :
"Unable to cast object of type 'Microsoft.SharePoint.Client.File' to type 'System.Management.Automation.PSObject' ".
Resolution:
It is observed that "Microsoft.SharePointOnline.CSOM" contains SharePoint and Project Client Object Model libraries . Post verifying through the available variable types, “Microsoft.SharePoint.Client.File” or some relevant type might not be found leading to this issue.
- Install the "Microsoft.SharePointOnline.CSOM" package from the nuget feed within UiPath Studio and then the "Microsoft.Sharepoint.Client.File" data type can be found.