Execution policy controls whether you can run PowerShell scripts or not. It is not a mechanism to prevent evil hackers from running scripts. Instead, it is just a safety belt for your own security so you don’t accidentally run unsafe scripts.
That’s why you can (almost) always change settings to enable PowerShell scripts:
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Bypass -Force
The only scenario where this won’t work is when domain admins have implemented a group policy and (accidentally) did not use a preference GPO but instead enforced it. Then, the GPO settings always rule.
You can however still enable scripts with a line of low level code. Ok, it is a very long line. You would have to launch PowerShell and paste the line into the interactive console (since you cannot run a script).
$context = $executioncontext.gettype().getfield('_context','nonpublic,instance').getvalue($executioncontext); $field = $context.gettype().getfield('_authorizationManager','nonpublic,instance'); $field.setvalue($context,(new-object management.automation.authorizationmanager 'Microsoft.PowerShell'))
You can test this by using Set-ExecutionPolicy to disable scripts. Then, run the line above, and you can run scripts. This setting is valid only for the session the line above was executed in.
Now is this a security issue? No. You should always be able to take off your seat belt if you like. Security needs to be enforced at a different level. If you wanted to prevent PowerShell scripts for security reasons, use a Software Restriction Policy or similar technology.