PowerShell is a very capable scripting language that is provided by modern Microsoft operating systems like Windows 8, Windows 10, and Windows servers. As a capable scripting language, it can be used by both Administrators and attackers. In order to secure the PowerShell scripting environment, the Execution Policy is provided. In order to run 3rd party PowerShell scripts, the execution policy should be set as
List Current Execution Policy
There are different execution policies like
Restricted etc. The currently active policy can be listed by using the
The output is
Restricted which means the current PowerShell execution policy is restricted and 3rd party scripts can not be executed.
Set Execution Policy As Unrestricted For The Current User
Set-ExecutionPolicy is used to change the current PowerShell execution policy. The policy name is provided as a parameter to the command Set-ExecutionPolicy. The following command sets the PowerShell execution policy as Unrestricted. In order to change the PowerShell execution policy for the current user, the option
-Scope is provided with the value
Set-ExecutionPolicy -Scope CurrentUser Unrestricted
The following message is provided in order to apply the policy change.
The execution policy helps protect you from scripts that you do not trust. Changing the execution policy might expose you to the security risks described in the about_Execution_Policies help topic at https:/go.microsoft.com/fwlink/?LinkID=135170. Do you want to change the execution policy? [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): A
Ychange execution policy for this shell.
Achanges execution policy for the current user.
Ndoes not change execution policy.
Set PowerShell Execution Policy Unrestricted For All Users
The PowerShell execution policy can be also set unrestricted for all users. But this operation requires Administrative privileges. So first we open the PowerShell with Administrator privileges by typing
PowerShell to the Start Menu.
Now by using the Administrative privileges PowerShell terminal execute following command.