How to disable script execution in powershell

Source: Internet
Author: User

When you start using powershell, when importing the management module or other operations, an error is reported because the script cannot be executed in this system. The error message is as follows:

 
Windows powershell
Copyright (c) 2009 Microsoft Corporation. All rights reserved.

PS c: \ windows \ system32> D: \ workshop \ powershell \ sprinkler \ SRC \ scripts \ sprinkle. PS1
The file D: \ workshop \ powershell \ sprinkler \ SRC \ scripts \ sprinkle. PS1 cannot be loaded because the script cannot be executed in this system. For more information, see
Reading"Get-help about_signing".
Location line: 1 character: 58
+ D: \ workshop \ powershell \ sprinkler \ SRC \ scripts \ sprinkle. PS1 <
+ Categoryinfo: notspecified: (:) [], pssecurityexception
+ Fullyqualifiederrorid: runtimeexception

PS c: \ windows \ system32> Get-executionpolicy

Restricted

Indeed, it is restricted. Still in"Get-help about_signing"You can find the setting command"Set-executionpolicy"

Find"Set-executionpolicy.. It seems that it is recommended to set it to, at least marked as trusted.

-- Remotesigned: requires that all scripts and configuration files downloaded from the Internet be signed by a trusted publisher.

Run the following command in powershell:

PS c: \ windows \ system32> set-executionpolicy remotesigned

Execute Policy Change

Executing policies prevents you from executing untrusted scripts. Changing the execution policy may expose you to about_execution_policies

Security risks described in the help topic. Do you want to change the execution policy?

[Y] Yes (y) [N] No (n) [s] suspend (s) [?] Help (default value: "Y"): Y

PS c: \ windows \ system32>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.