700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > powershell导入脚本失败 禁止运行脚本 无法远程连接服务器

powershell导入脚本失败 禁止运行脚本 无法远程连接服务器

时间:2021-09-24 10:47:55

相关推荐

powershell导入脚本失败 禁止运行脚本 无法远程连接服务器

报错:

Import-Module : 无法加载文件 C:\Users\t\Desktop\nishang-master\nishang.psm1,因为在此系统上禁止运行脚本。有关详细信息,请参阅 https://fwlink/?LinkID=135170 中的 about_Execution_Policies。所在位置 行:1 字符: 1+ Import-Module .\nishang.psm1+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ CategoryInfo: SecurityError: (:) [Import-Module],PSSecurityException+ FullyQualifiedErrorId : UnauthorizedAccess,mands.ImportModuleCommand

以管理员身份运行powershell

查询计算机上的现用执行策略

get-executionpolicyRestricted

解决:(执行策略更改为 RemoteSigned)

set-executionpolicy Unrestricted

导入脚本后

查看模块命令Get-Command -Module nishang

出现模块即导入成功

一般来说powershell导入脚本失败的原因是powershell策略的问题

查看当前系统powershell的执行策略:

Get-ExecutionPolicy

若要获取影响当前会话的所有执行策略:

Get-ExecutionPolicy -List

设置策略是

Set-ExecutionPolicy 策略名

设置某个特定作用域中的执行策略

set-executionpolicy 策略名 -Scope CurrentUser

具体策略有:.

Unrestricted:允许所有的脚本执行。 —危险Restricted:脚本不能运行;

RemoteSigned:本地创建的脚本可以执行,但是网上下载的不允许;.

AllSigned:脚本有受信任的发布者签名时才能执行;u

Bypass:绕过安全策略执行脚本

AllSigned 和 RemoteSigned 执行策略可防止 Windows PowerShell 运行没有数字签名的脚本。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。