The PowerShell Execution Policy
The execution policy of PowerShell enabled you to configure which PowerShell scripts are allowed, if they are allowed at all, to be executed. You can get the currently active execution policy with the following command: “Get-ExecutionPolicy”.
The PowerShell execution policy has six kinds of flavor:
Changing the execution policy
To change the PowerShell execution policy you can use the “Set-ExecutionPolicy” cmdlet, for example “Set-ExecutionPolicy AllSigned”. When you change the execution policy, you will be prompted with a warning that you’re changing the it.
If you don’t want to get that confirmation you can simply use the “-Force” parameter behind your command. For example, the “Set-ExecutionPolicy RemoteSigned –Force” command will change the execution policy to “RemoteSigned” without prompting you for a confirmation.
If you want to be sure this confirmation prompt to appear you can use the “-Confirm” parameter to make sure of that.
The scope of the execution policy
There are three different scopes for the execution policy:
The scope can be set with the “-Scope” parameter as an addition to the “Set-ExecutionPolicy” command and it can be removed by setting the execution policy for that scope to “Undefined”.
Bypassing the execution policy
There is a secret parameter called “-”. When you use it, you can pipe a script into powershell.exe and execute it line. Here is an example: “Get-Content ‘C:\somescript.ps1′ | powershell.exe -noprofile -”

Categories
Tag Cloud
Blog RSS
Comments RSS
Last 50 Posts
Back
Void « Default
Life
Earth
Wind
Water
Fire
Light 