Invoke Power Shell: Unable to cast object to type 'System.IO.FileInfo' to type 'System.String'

Hi,

I was using ‘Invoke Power Shell’ activity, it works fine most of the times, but sometimes it throws any of the below three error messages.

  1. Invoke Power Shell: Unable to cast object to type ‘System.IO.FileInfo’ to type ‘System.String’
  2. Invoke Power Shell: Unable to cast object of type ‘System.UnauthorizedAccessException’ to type ‘System.String’.
  3. Invoke Power Shell: Unable to cast object of type ‘System.Exception’ to type ‘System.String’.

I hereby attach screenshots for your references. Kindly review and guide me to resolve this issue

Picture1
Picture2


Regards
Suraj.S

Could you please use the parameters in powershell script as mentioned below

[Parameter(Mandatory=$true)] [string]$SourcePath