How to run PowerShell scripts with Studio 23.4?
After upgrading to Studio / Robot 2023.4, running using "Invoke PowerShell" activity with a script will throw the following error,
File [path] cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https://go.microsoft.com/fwlink/?LinkID=135170.
Initial Activity Configuration:
Root Cause: Windows projects execute internal PowerShell version that uses its own set of execution policies and not the one on the machine. And providing just the path to the script acts as trying to execute the script already, and that is blocked by those internal execution policies.
- Add the execution policy right before the script path, using a break line:
- Use "Read Text File" and use its output for "Invoke PowerShell". Also enable "IsScript".