Home > Enterprise >  Set-ExecutionPolicy Restricted should I use it like that always?
Set-ExecutionPolicy Restricted should I use it like that always?

Time:06-07

I was getting error when I try to use NPM commands on powershell (Win11) and I fixed it with this powershell command:

Set-ExecutionPolicy RemoteSigned

But I'm unsure if I can leave it like that for always is it safe to leave it like that? Or should I turn it back to default with this command:

Set-ExecutionPolicy Restricted

CodePudding user response:

Putting this here as it is too long for a normal comment.

Please read the documents in PS Execution Policies.

about_Execution_Policies https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-7.2

PowerShell's execution policy is a safety feature that controls the conditions under which PowerShell loads configuration files and runs scripts. This feature helps prevent the execution of malicious scripts.

Execution policies as per Microsoft are not a security boundary.

Execution policies can easily be bypassed as needed.

15 Ways to Bypass the PowerShell Execution Policy https://www.netspi.com/blog/technical/network-penetration-testing/15-ways-to-bypass-the-powershell-execution-policy/

By default PowerShell is configured to prevent the execution of PowerShell scripts on Windows systems. This can be a hurdle for penetration testers, sysadmins, and developers, but it doesn’t have to be. In this blog, I’ll cover 15 ways to bypass the PowerShell execution policy without having local administrator rights on the system. I’m sure there are many techniques that I’ve missed (or simply don’t know about), but hopefully, this cheat sheet will offer a good start for those who need it.

Should they be used, yes, but they are only a short hurdle to overcome by experienced folks, but regular users would not usually know that.

You can set restricted or remoteSigned for the host (MachinePolicy), but run scripts using whatever policy you choose for your user profile (Process or CurrentUser).

You can have multiple PS instances all running with different EP's.

  • Related