Allowing PowerShell Script Execution – No Matter What

Execution policy can prevent scripts from running. It is designed to be a user preference setting, so you should always be able to change the effective execution policy. In some environments, though, group policy forces settings on you and may prevent running scripts.

In such a case, it might be an option for you to reset the internal PowerShell authorization manager. Once you replace it with a default instance, you can run PowerShell scripts regardless of any previous execution policy setting:

$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'))

Remember: this is not a security issue. Execution policy is meant to be controlled by the user. It is not a security boundary.

Twitter This Tip! ReTweet this Tip!

GD Star Rating