Skip to content

Instantly share code, notes, and snippets.

@AdilHindistan
Last active June 19, 2018 20:03
Show Gist options
  • Save AdilHindistan/31b2482e0f7e3ce8eeb294674a01eee2 to your computer and use it in GitHub Desktop.
Save AdilHindistan/31b2482e0f7e3ce8eeb294674a01eee2 to your computer and use it in GitHub Desktop.
Fix PSGallery Registration
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