Leona+ Dream for future

3Feb/100

Execution Policy in Powershell

Powershell is a powerful tool that may be used to replace traditional batch command line. But by default, Powershell doesn't allow executing script file, (maybe for security reasons). Executing Powershell script will cause the following error message:

File <file_url> cannot be loaded because the execution of scripts is disabled on this system. Please see "get-help about_signing" for more details.
At line:1 char:11

+ .\<file_name> <<<<
    + CategoryInfo          : NotSpecified: (:) [], PSSecurityException
    + FullyQualifiedErrorId : RuntimeException

This is because the default Execution Policy is Restricted, which means Powershell permits individual commands, but will not run scripts, including formatting and configuration files (.ps1xml), module script files (.psm1), and Windows PowerShell profiles (.ps1).

The solution is to loosen the policy, for example, set it to RemoteSigned or Unrestricted. Just run the following command in Powershell:

1
Set-ExecutionPolicy RemoteSigned

Then it alerts:

Execution 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. Do you want to change the execution policy?

Press Y and it's done.

Filed under: Software Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


No trackbacks yet.