Run Set-ExecutionPolicy Bypass script when opening a new terminal

Hi. My company has some policies and every time I want to activate my environment in the PowerShell terminal I have to run first

Set-ExecutionPolicy Bypass -Scope Process

I saw that there's an option to activate the environment every time I open a new terminal. Can I specify to run the previous line of command before attempting to activate the environment? I have PyCharm 2022.3 (Professional Edition).

Thanks in advance!

0
Hello,

Unfortunately, there is no such option, but you can use CMD, which doesn't require tweaking policies in order to activate the environment.
1

Hi Nicolas,

I found that you can add an env var for this per h**ps://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-7.3

"The execution policy is saved in the environment variable $env:PSExecutionPolicyPreference, rather than the registry. When the PowerShell session is closed, the variable and value are deleted."

So I added in terminal settings under “Environmental Variables” - PSExecutionPolicyPreference=Bypass, which resolved the warning you get.

0

请先登录再写评论。