当前位置: 移动技术网 > IT编程>脚本编程>Shell > Powershell脚本的4种执行权限介绍

Powershell脚本的4种执行权限介绍

2017年12月08日  | 移动技术网IT编程  | 我要评论

restricted——默认的设置, 不允许任何script运行
allsigned——只能运行经过数字证书签名的script
remotesigned——运行本地的script不需要数字签名,但是运行从网络上下载的script就必须要有数字签名
unrestricted——允许所有的script运行

windows默认不允许任何脚本运行,你可以使用"set-executionpolicy"cmdlet来改变的你powershell环境。例如,你可以使用如下命令让powershell运行在无限制的环境之下:


set-executionpolicy unrestricted

但在win7下,必须使用管理员的权限启动命令命令行,否则会报“set-executionpolicy : 对注册表项“hkey_local_machine\software\microsoft\powershell\1\shellids\microsoft.powershell”的访问被拒绝。”错误。

使用java调用powershell脚本,可以使用以下命令:


string cmd = "cmd /c powershell -executionpolicy remotesigned -noprofile -noninteractive -file \""+ scriptfilename + "\"";

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网