關於解決PowerShell 訪問PSGallery的InstallationPolicy爲Untrusted的問題.

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

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章