Last active
June 19, 2018 20:03
-
-
Save AdilHindistan/31b2482e0f7e3ce8eeb294674a01eee2 to your computer and use it in GitHub Desktop.
Fix PSGallery Registration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Fix-PSRepository { | |
<# | |
Fixes the issue with PSGallery: | |
Find-Module <module_name> -> does not find anything | |
Get-PSRepository -> returns "Unable to find module repositories" | |
Register-PSRepository -Default -Verbose -> should fix it but behind the proxy, following should be run first | |
#> | |
[system.net.webrequest]::defaultwebproxy = new-object system.net.webproxy('http://proxy_address:proxy_port') | |
[system.net.webrequest]::defaultwebproxy.credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials | |
[system.net.webrequest]::defaultwebproxy.BypassProxyOnLocal = $true | |
# now this should work and register the PSGallery as default | |
Register-PSRepository -Default -Verbose | |
# And this should return PSGallery with its installation policy and source location | |
Get-PSRepository | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment