Just to add something. If you are using Studio Windows projects, then the Invoke PowerShell will use the PowerShell 7.1 available in the PowerShell SDK that comes with the System package and not your machine installation of PS.
This means that your normal execution policies will not affect the actual process.
You can easily fix that by adapting the policy at the start of your script, i.e. like so:
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope Process
Thankyou for this excellent tip.
Unfortunately I need to run a module called PnP.PowerShell in this 7.1 bundled powershell - how do I do that? I have PS5.x on my machine and the module is installed there. When I run the automation that uses an Invoke-PowerShell -activity, it does not find the PnP.PowerShell module at all.
How do i tell UiPath Studio and Robot where to find the module, if its in a “bundled” version of PS and not the machine’s actual PS?
This problem occured once i patched studio to version 2023.4, before that it worked perfectly.