Friday, February 27, 2015

Working with Powershell locked down? Unlock it…

 

If the machine you are running on and locked down there are several options to running the scripts shown below.

image

Via PowerShell - Get-Content AScript.ps1 | Invoke-Expression

image

Via DOS (note the spurious characters coming from the piped file) – TYPE AScript.ps1 | PowerShell.exe -noprofile

image

Or via a script to disable the execution policy by removing the AuthorizationManager in the current PowerShell session:

function Disable-ExecutionPolicy {($ctx = $executioncontext.gettype().getfield("_context","nonpublic,instance").getvalue( $executioncontext)).gettype().getfield("_authorizationManager","nonpublic,instance").setvalue($ctx, (new-object System.Management.Automation.AuthorizationManager "Microsoft.PowerShell"))} Disable-ExecutionPolicy

image

I found this here: –> https://blog.netspi.com/15-ways-to-bypass-the-powershell-execution-policy/

Post a Comment

Blog Archive