PowerShell安裝模塊時,可能會提示無法訪問PSGallery,此時Get-PSRepository執行後獲得InstallationPolicy是untrusted.
如果直接執行
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