powershell无法安装模块的解决方法

微软PowerShell无法安装模块,提示:Install-Module : 在模块“PowerShellGet”中找到“Install-Module”命令,但无法加载该模块。有关详细信息,请运行“Import-Module PowerShellGet”。

当运行Import-Module PowerShellGet后:显示:

Import-Module : 无法加载文件 C:\Users\xxx\Documents\WindowsPowerShell\Modules\PackageManagement\1.4.7\PackageManagement.psm1,因为在此系统上禁止运行脚本
。有关详细信息,请参阅 https:/go.microsoft.com/fwlink/?LinkID=135170 中的 about_Execution_Policies。
所在位置 行:1 字符: 1
+ Import-Module PowerShellGet
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : SecurityError: (:) [Import-Module],PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess,Microsoft.PowerShell.Commands.ImportModuleCommand

原因:

在计算机上启动 Windows PowerShell 时,执行策略很可能是 Restricted(默认设置)。

powershell 输入:get-executionpolicy

image-20211209113303018

显示为: Restricted

解决方法:

修改执行策略:

输入: set-executionpolicy remotesigned

image-20211209113355507

  • 4
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值