When Powershell scripts directly, it appears: The file ******.ps1 cannot be loaded because the execution of scripts is prohibited in this system. For more information, see get-help about_signing. Location: Line: 1 Characters: 17 + E:\Test\test.ps1 <<<< + CategoryInfo : NotSpecified: (:) [], PSSecurityException + FullyQualifiedErrorId : RuntimeException Check out the "get-help about_signing": Topic about_signing Short description Explains how to sign a script to make it compliant with Windows PowerShell execution policies. Detailed description The Restricted execution policy does not allow any scripts to run. The AllSigned and RemoteSigned execution policies prevent Windows PowerShell from running scripts without a digital signature. This topic explains how to run the selected unsigned script (even if the execution policy is RemoteSigned) and also explains how to do it correctly Script to sign for your own use. For more information about Windows PowerShell enforcement policies, see about_Execution_Policy. Allows the running of signature scripts When you first start Windows PowerShell on your computer, the current execution policy is likely to be Restricted (the default setting). The Restricted policy does not allow any scripts to run. To understand the active execution policy on your machine, type: get-executionpolicy To run unsigned scripts that you wrote and signed scripts from other users on your local machine, use the following command to run unsigned scripts that you wrote on your computer Execution policy changes to RemoteSigned: set-executionpolicy remotesigned For more information, see Set-ExecutionPolicy.
Execute "set-ExecutionPolicy RemoteSigned": Execute policy changes Execution policies prevent you from executing scripts you don't trust. Changing your execution policy can expose you to about_Execution_Policies The security risks described in the help topic. Do you want to change your enforcement policy? [Y] Yes (Y) [N] No (N) [S] Suspend(S) [?] Help (default is "Y"): y
PowerShell is undoubtedly security-minded, and it divides script execution into several strategies. Here are 4 commonly used execution strategies:
Restricted: Running any scripts and configuration files is prohibited.
AllSigned : Scripts can be run, but all scripts and configuration files must be signed by a trusted publisher, including scripts written on the local machine.
RemoteSigned : scripts can be run, but scripts and configuration files downloaded from the network must be signed by a trusted publisher; Digitally signing scripts that have already been run and written on the local machine is not required.
Unrestricted : Unsigned scripts can be run. (Danger!) )
If you still get an unexecuteable error, try Set-ExecutionPolicy Unrestricted
|