关于解决PowerShell 访问PSGallery的InstallationPolicy为Untrusted的问题.

PowerShell安装模块时,可能会提示无法访问PSGallery,此时Get-PSRepository执行后获得InstallationPolicy是untrusted.

关于解决PowerShell 访问PSGallery的InstallationPolicy为Untrusted的问题._第1张图片

如果直接执行

Set-PSRepository -Name PSGallery -InstallationPolicy trusted

是无法生效的,因为.net4中没有启用额外的加密协议,会导致访问PSGallery失败.

此时需要向.net4的注册表添加安全协议生效的项目

Set-ItemProperty -Path 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NetFramework\v4.0.30319' -Name 'SchUseStrongCrypto' -Value '1' -Type DWord
Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\.NetFramework\v4.0.30319' -Name 'SchUseStrongCrypto' -Value '1' -Type DWord

然后再次执行

Set-PSRepository -Name PSGallery -InstallationPolicy trusted

 

你可能感兴趣的:(powershell,powershell)