File C:\Temp\Test.ps1 cannot be loaded because the execution of scripts is disabledon this system.
2015-02-05 18:06
567 查看
PowerShell 默认不允许执行*.ps1脚本文件。运行ps1文件会得到下面的错误:
File C:\Temp\Test.ps1 cannot be loaded because the execution of scripts is disabledon this system. Please see "get- help about_signing" for moredetails.
At line:1char:19
+ c:\Temp\Test.ps1 <<<<
可以通过Get-ExecutionPolicy,来取得当前策略。
用Set-ExecutionPolicy设置当前策略。
下面的命令可以解决上面的错误
PS C:\Windows\system32> Set-ExecutionPolicy RemoteSigned <按回车>
ExecutionPolicy Change
Theexecution policy helps protect you from scripts that you do not trust. Changingthe execution policy might expose
you tothe security risks described in the about_Execution_Policies help topic. Do youwant to change the execution
policy?
[Y] Yes
No [S] Suspend [?] Help (default is "Y"):<按Y>
在PowerShell中的执行
Policy的有效参数:
-- Restricted: 不载入任何配置文件,不运行任何脚本。 "Restricted" 是默认的。
--AllSigned: 只有被Trusted publisher签名的脚本或者配置文件才能使用,包括你自己再本地写的脚本
--RemoteSigned: 对于从Internet上下载的脚本或者配置文件,只有被Trusted publisher签名的才能使用。
--Unrestricted: 可以载入所有配置文件,可以运行所有脚本文件. 如果你运行一个从internet下载并且没有签名的脚本,在运行之前,你会被提示需要一定的权限。
--Bypass: 所有东西都可以使用,并且没有提示和警告.
-- Undefined: 删除当前scope被赋予的Execution Policy. 但是Group Policy scope的Execution Policy不会被删除.
File C:\Temp\Test.ps1 cannot be loaded because the execution of scripts is disabledon this system. Please see "get- help about_signing" for moredetails.
At line:1char:19
+ c:\Temp\Test.ps1 <<<<
可以通过Get-ExecutionPolicy,来取得当前策略。
用Set-ExecutionPolicy设置当前策略。
下面的命令可以解决上面的错误
PS C:\Windows\system32> Set-ExecutionPolicy RemoteSigned <按回车>
ExecutionPolicy Change
Theexecution policy helps protect you from scripts that you do not trust. Changingthe execution policy might expose
you tothe security risks described in the about_Execution_Policies help topic. Do youwant to change the execution
policy?
[Y] Yes
No [S] Suspend [?] Help (default is "Y"):<按Y>
在PowerShell中的执行
Policy的有效参数:
-- Restricted: 不载入任何配置文件,不运行任何脚本。 "Restricted" 是默认的。
--AllSigned: 只有被Trusted publisher签名的脚本或者配置文件才能使用,包括你自己再本地写的脚本
--RemoteSigned: 对于从Internet上下载的脚本或者配置文件,只有被Trusted publisher签名的才能使用。
--Unrestricted: 可以载入所有配置文件,可以运行所有脚本文件. 如果你运行一个从internet下载并且没有签名的脚本,在运行之前,你会被提示需要一定的权限。
--Bypass: 所有东西都可以使用,并且没有提示和警告.
-- Undefined: 删除当前scope被赋予的Execution Policy. 但是Group Policy scope的Execution Policy不会被删除.
相关文章推荐
- File xxx.ps1 cannot be loaded because the execution of scripts is disabled on this system
- PS1--cannot be loaded because the execution of scripts is disabled on this system
- PowerShell: 如何解决File **.ps1 cannot be loaded because the execution of scripts is disabled on this system. Please see "get- help about_sig" for more de
- PowerShell: 如何解决File **.ps1 cannot be loaded because the execution of scripts is disabled on this system.
- PowerShell: 如何解决File **.ps1 cannot be loaded because the execution of scripts is disabled on this sy
- PowerShell: 如何解决File **.ps1 cannot be loaded because the execution of scripts is disabled on this sy
- windows powershell错误 because the execution of scripts is disabled on this system
- “System.IO.FileLoadException: Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 错误
- “The execution of scripts is disabled on this system” … How to run your own PowerShell scripts
- 解决方案: the selected file is a solution file but was created by a newer version of this application and cannot be opened
- [转] EF cannot be tracked because another instance of this type with the same key is already being tracked
- This is usually because the "vboxsf" file system is not available.
- This action cannot be completed because the other application is busy
- java.lang.SecurityException: Filter of class org.apache.catalina.ssi.SSIFilter is privileged and cannot be loaded by this web application
- System.Web.HttpException: The file "~/xxx//Index.cshtml" cannot be requested directly because it cal
- 奇葩问题:This file could not be checked in because the original version of the file on the server was moved or deleted. A new version of this file has been saved to the server, but your check-in comments were not saved
- Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additio
- Cannot modify the return value of 'System...ClientRectangle' because it is not a variable
- Database 'xxx' cannot be upgraded because it is read-only or has read-only file Make the database or files writeable, and rerun recovery.
- fix errors 1088: “Failed to execute request because the App-Domain could not be created. Error: 0x80070005 Access is denied” and 1334: “Exception: System.IO.FileLoadException”