Often you might need to execute an unsigned script that doesn't comply with the current execution policy. An easy way to do this is by bypassing the execution policy for that single process. Example:
powershell.exe -ExecutionPolicy Bypass -File C:\MyUnsignedScript.ps1
Or you can use the shorthand:
powershell -ep Bypass C:\MyUnsignedScript.ps1
Policy | Description |
---|---|
AllSigned | Only scripts signed by a trusted publisher can be run. |
Bypass | No restrictions; all Windows PowerShell scripts can be run. |
Default | Normally RemoteSigned , but is controlled via ActiveDirectory |
RemoteSigned | Downloaded scripts must be signed by a trusted publisher before they can be run. |
Restricted | No scripts can be run. Windows PowerShell can be used only in interactive mode. |
Undefined | NA |
Unrestricted * | Similar to bypass |
Unrestricted*
Caveat: If you run an unsigned script that was downloaded from the Internet, you are prompted for permission before it runs.
More Information available here.