Invoke PowerShell Activity - Can't launch script from network share

I’ve got a process that runs a local script via Invoke-Expression without issue. However if I move the script to a network share and input the new location, receive an error indicating a cast error as shown below;

Capture

I’ve tried passing the path as a variable as well as hard coding it in UIPath Invoke-PowerShell Activity argument to no avail. If I run the same command/script as per below direct in PowerShell there is no error.

Invoke-Expression "\\Server\Path\MorePath\MorePath\Set-DefaultPrinterFinance.ps1"

Here is sample XAML.

Set Default Printer.xaml (6.3 KB)

Is there a known fix/workaround for this issue?

Thanks :slight_smile:

Unfortunately, I’m not sure what the issue is right away.

Since you are just trying to execute a .ps1 file, from the looks of it, you can invoke it like this also:
image

Regards.

Oh also, if you still get the error, then it might be coming from the “Set-DefaultPrinterFinance.ps1” file. You could also look up that error online to seek out solutions that may help if we can’t.

Hi Clayton. Thanks for responding. Can you confirm what is the activity or package name?

Yeah, here’s a screenshot showing the package and activity name:

Here is a demo of the issue using a network share.

Here is demo using an alternate local path.

Here is evidence the script is located where it is supposed to be.

Here is evidence the command runs in PowerShell without issue.

1 Like

Thanks Clayton. That activity allows me to run the script without issue :slight_smile: