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.


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


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


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


I found this here: –>

No comments:

Blog Archive