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>