Powershell中禁止执行脚本解决办法(about_Execution_Policies)
2016-05-22 13:15
726 查看
Powershell中禁止执行脚本解决办法 - 张善友 - 博客园 http://www.cnblogs.com/shanyou/archive/2011/09/03/2165371.html
刚开始使用Powershell,导入管理模块或者其他操作的时候会出现因为在此系统中禁止执行脚本的报错,报错内容如下:
PS C:\Windows\system32>
get-ExecutionPolicy
(查询当前策略设置)
Restricted (guyue: 受限制的)
果然,是被限制。还是在"get-help about_signing"里面可以查到设置命令"set-executionpolicy"
再在帮助中找到"set-executionpolicy"的说明。。似乎是比较建议设置为,至少是被标记为可信任的
-- RemoteSigned: Requires that all scripts and configuration files downloaded from the Internet be signed by a trusted publisher.
在PowerShell执行以下:
PS C:\Windows\system32> set-ExecutionPolicy RemoteSigned
(修改策略以执行prowershell脚本)
执行策略更改
执行策略可以防止您执行不信任的脚本。更改执行策略可能会使您面临 about_Execution_Policies
帮助主题中所述的安全风险。是否要更改执行策略?
[Y] 是(Y)
否(N) [S] 挂起(S) [?] 帮助 (默认值为“Y”): y
之后即可执行prowershell脚本, 例如
PS C:\Windows\system32>./1.ps1
(执行脚本)
Powershell中禁止执行脚本解决办法(about_Execution_Policies)
刚开始使用Powershell,导入管理模块或者其他操作的时候会出现因为在此系统中禁止执行脚本的报错,报错内容如下:Windows PowerShell 版权所有 (C) 2009 Microsoft Corporation。保留所有权利。 PS C:\Windows\system32> D:\Workshop\Powershell\Sprinkler\src\Scripts\SPRINKLE.ps1 无法加载文件 D:\Workshop\Powershell\Sprinkler\src\Scripts\SPRINKLE.ps1,因为在此系统中禁止执行脚本。有关详细信息,请参 阅 "get-help about_signing"。 所在位置 行:1 字符: 58 + D:\Workshop\Powershell\Sprinkler\src\Scripts\SPRINKLE.ps1 <<<< + CategoryInfo : NotSpecified: (:) [], PSSecurityException + FullyQualifiedErrorId : RuntimeException
PS C:\Windows\system32>
get-ExecutionPolicy
(查询当前策略设置)
Restricted (guyue: 受限制的)
果然,是被限制。还是在"get-help about_signing"里面可以查到设置命令"set-executionpolicy"
再在帮助中找到"set-executionpolicy"的说明。。似乎是比较建议设置为,至少是被标记为可信任的
-- RemoteSigned: Requires that all scripts and configuration files downloaded from the Internet be signed by a trusted publisher.
在PowerShell执行以下:
PS C:\Windows\system32> set-ExecutionPolicy RemoteSigned
(修改策略以执行prowershell脚本)
执行策略更改
执行策略可以防止您执行不信任的脚本。更改执行策略可能会使您面临 about_Execution_Policies
帮助主题中所述的安全风险。是否要更改执行策略?
[Y] 是(Y)
否(N) [S] 挂起(S) [?] 帮助 (默认值为“Y”): y
之后即可执行prowershell脚本, 例如
PS C:\Windows\system32>./1.ps1
(执行脚本)
相关文章推荐
- Shell 脚本编程陷阱
- VBS脚本写的Windows硬件检测工具分享
- 用vbscript实现隐藏任务栏图标的脚本
- 用autoit编写第一个脚本(Hello World)
- 在flex中执行一个javascript方法的简单方式
- VBS调用WMI快速关闭IE的脚本
- Oracle数据库执行脚本常用命令小结
- 收集的ROS防火墙脚本
- JSP脚本漏洞面面观
- 不错的批处理脚本 第一部分
- VBS脚本加密/解密VBS脚本(简易免杀版1.1)
- 不错的批处理脚本实例代码 第二部分
- 使用脚本和批处理清除电脑中的痕迹的代码第1/2页
- 让你的脚本说话
- Lua中编译执行代码相关的函数详解
- Lua脚本获取喜马拉雅MP3音频地址
- SQL Server中数据行批量插入脚本的存储实现
- 编程界主流脚本编程语言的比较和选择