Invoke powershell -scripts diabled / execution policy

I am getting issues running powershell - scripts are disabled etc - what should the execution policy be? Surely UIPath has a how to set up the execution policy for windows 10/2019 etc ?

I heavily use powershell to automate stuff in my day to day job and the ability to use it when i cant get what i need from the UIpath UI (Yes i am learning C# too), but this is holding me back

I can use the start process, but that flashes up a blue screen every time its invoked - can someone please advise?

Thanks again for your help on this !

Phil

PS i am GMT so i may not pick up any replies/responses until Sunday (Tomorrow morning GMT) , just so that you know i am not being ignorant !

:slight_smile:

Hi @philwaller

So execution policy is to be unrestricted or should be bypass

Cheers

Hello @philwaller
Please check the below video.

Thanks

Hi @philwaller

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

Thank you !

Very much appreciated !

Thanks, unfortunately i have the same issue

using start process for the time being!

dont think its an issue on server OS only on Desktop OS as all my server / UiPath deployments seem to work without issue ! - i think! :slight_smile:

Is it resolved now?

Thanks

Hi Rahul

No it wasnt

It works on server OS but not on desktop OS

Not to worry for the moment as i have a workaround

Thanks again!

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.

Is upgrading my machines PS to 7.1 the solution?

Just to update. System 23.12 will introduce an option to select your desired runtime for the power shell. It should help fix any further issues.

Hi,

When I am running the PowerShell script on local machine manually. It is running successfully but when I am trying to run the PowerShell from UiPath. It’s gives the access error. Screenshot is attached
PowerShell_Error