How to Fix the “PowerShell Gallery is Currently Unavailable” Error

The PowerShell Gallery is an online repository for sharing and acquiring PowerShell code, like modules and scripts. It allows PowerShell users to easily find, download, and install pre-made solutions to automate tasks on Windows.

However, you may sometimes encounter the error “PowerShell Gallery is currently unavailable” when trying to access the gallery. This prevents you from browsing or installing modules from the repository.

In this comprehensive guide, I’ll explain what causes this error and the different methods you can use to resolve the issue on Windows 10/11.

There are a few potential reasons why you may see this error message:

  • Your network connection is blocked from accessing the PowerShell Gallery website. This could be due to firewall policies, web filtering, or proxy server issues.
  • The PowerShell Gallery website is temporarily down for maintenance. The site does go offline on rare occasions for updates.
  • There are problems with the PowerShellGet module, which powers interaction with the gallery. It may be outdated, corrupted, or misconfigured on your system.
  • System-wide issues like DNS name resolution failures, TLS/SSL problems, or antivirus software could block access to the gallery.
  • You don’t have permission to access the repository. For example, access may be prohibited on locked down corporate networks.

The most common root causes relate to network connectivity and the PowerShellGet module. So the solutions below focus on troubleshooting those areas.

First, verify that you can reach the PowerShell Gallery website by name. Open a PowerShell prompt and run:

Test-NetConnection powershellgallery.com -Port 443

If it fails, your system cannot resolve the domain or connect over the network. Try fixing it with these steps:

  • Restart your network devices and PC. Transient network issues can resolve themselves.
  • Try visiting the URL in a web browser. If it fails, the problem is network access.
  • Verify your DNS settings can resolve public internet names.
  • Disable any VPNs, proxies, firewalls, or web filters temporarily to test access.
  • Run network diagnostics in Windows Settings app.
  • Ensure your antivirus/security software is not blocking connections.
  • Check for host file modifications that could block the domain.

Once you can reach the site by name, test connectivity using HTTPS:

Test-NetConnection powershellgallery.com -Port 443 -InformationLevel Detailed

Look for TLS/SSL errors in the verbose output. If you see any, try these fixes:

  • Make sure system date/time is correct.
  • Check for certificate store corruption issues.
  • Verify no other devices are intercepting traffic.
  • Renew the trusted root certificates on your system.
  • Disable intrusion detection softwares temporarily.

After troubleshooting network problems, try accessing the gallery again. If the issue persists, switch to debugging PowerShellGet next.

Fix 2 – Update the PowerShellGet Module

The PowerShellGet module contains the commands used to interact with repositories like the PowerShell Gallery. An outdated or broken version can cause connectivity issues.

First, check your installed PowerShellGet version:

Get-InstalledModule -Name PowerShellGet -AllVersions

Ideally, it should match the latest stable release. Compare yours against the current version at:

https://www.powershellgallery.com/packages/PowerShellGet

If it’s outdated, update PowerShellGet by running:

Install-Module -Name PowerShellGet -Force

Use -AllowClobber if it detects version conflicts. This downloads the latest version from the gallery to overwrite your old copy.

If installing fails, try these troubleshooting steps:

  • Temporarily disable antivirus software, which may block downloads.
  • Use the -SkipPublisherCheck parameter if seeing publisher verification messages.
  • Specify a -Repository manually if your configured repositories are blocked.
  • Run Get-PSRepository and ensure the PSGallery repository is registered.

Finally, confirm only one PowerShellGet version is installed:

Get-InstalledModule -Name PowerShellGet -AllVersions

Uninstall old copies if any remain.

Fix 3 – Reset the PowerShellGet Module

If updating PowerShellGet fails, you may need to reset the module to fix corruption or misconfiguration issues:

First, remove all versions of the module from your user profile:

Get-InstalledModule -Name PowerShellGet -AllVersions | Uninstall-Module -AllVersions

Next, remove leftover PowerShellGet files:

Remove-Item "$env:LOCALAPPDATA\Apps\2.0\*\Modules\PowerShellGet" -Recurse -Force

Finally, reimport a fresh copy from system modules:

Import-Module PowerShellGet

This should load the version bundled with your PowerShell installation, if available.

Now try updating or reinstalling PowerShellGet again. Be sure to restart your PowerShell session after resetting the module.

Fix 4 – Rebuild the PowerShellGet Cache

PowerShellGet caches metadata for modules in your user profile to optimize performance. If this cache is outdated or damaged, it can affect connectivity to repositories.

To rebuild the cache, first remove the existing data:

Remove-Item "$env:LOCALAPPDATA\Microsoft\Windows\PowerShell\PackageManagement\PackageCache" -Recurse -Force

Next, use PowerShellGet commands to populate fresh cache contents:

Get-PSRepository
Find-Module

Run repository and module queries until it finishes rebuilding.

Finally, restart your PowerShell session for changes to take effect.

Resetting the cache often resolves odd errors when searching for or installing modules.

Fix 5 – Modify Proxy and Security Settings

If you access the public internet via a proxy server, you may need to configure PowerShellGet to use it:

$proxy = 'http://proxy.example.com:8080'

[Net.WebRequest]::DefaultWebProxy.ProxyAddress = $proxy

Save the settings in your PowerShell profile so they persist across sessions.

You can also try temporarily disabling proxy use for testing:

[Net.WebRequest]::DefaultWebProxy = [Net.GlobalProxySelection]::GetEmptyWebProxy()

For corporate environments, you may need to change PowerShell execution policies so gallery access isn’t blocked:

Set-ExecutionPolicy RemoteSigned

Also whitelist the PowerShell Gallery if required by your security software.

If you cannot resolve issues with the official gallery, try configuring an alternate repository:

  • Private module repository – Set up your own NuGet server or gallery for internal use.
  • Public module repositories – There are a few community-run PowerShell repositories you can add instead.
  • Local module cache – You can download modules manually and install from a local path.

Here is an example adding the PSGallery replacement at https://www.poshtestgallery.com:

Register-PSRepository -Name LocalGallery -SourceLocation https://www.poshtestgallery.com/api/v2/ -InstallationPolicy Trusted

Now you can install modules by specifying -Repository LocalGallery.

This can help determine whether the root cause lies with the official PowerShell Gallery site or something on your local system.

Fix 7 – Use WebProxy Module as a Proxy

If you have no direct internet access, the WebProxy module lets you tunnel through a remote proxy server:

Install-Module -Name WebProxy
Import-Module WebProxy

Start-WebProxy -Uri http://remoteproxy:8080 -AsJob

The proxy is now running in the background. Next, configure PowerShellGet to use it:

$webproxy = New-WebProxyUri -Port 8080 -IpAddress 127.0.0.1

[System.Net.WebRequest]::DefaultWebProxy = $webproxy

Now PowerShell can access the gallery through your proxy connection.

Fix 8 – Use a Browser to Download Modules

As a workaround, you can manually download modules in a web browser if gallery access fails:

  1. Browse to https://www.powershellgallery.com and search for the desired module.
  2. On the module’s page, expand the “Download Package” link.
  3. Copy the “Direct Download” link for the latest module version.
  4. Paste the link into your browser to download the NUPKG file.
  5. Finally, install the local module file in PowerShell:
Install-Module -Name C:\Downloads\ModuleName
 Here is the continuation of the article:

## Troubleshooting Gallery Installation Failures

If installing modules from the gallery fails, there are a few things you can test:

**Verify the module exists:**

```powershell
Find-Module -Name ModuleName

If it’s not found, check for spelling errors or browse the gallery webpages.

Check for error messages:

Read the full error output for clues. Common messages include:

  • Unable to contact repository
  • No match was found for the specified search criteria
  • Module ‘X’ was not installed because module ‘Y’ is already installed
  • The credentials supplied to the package were incorrect

Test installing different modules:

See if the issue occurs for all modules or only a specific one.

Try finding and installing modules by exact name:

Find-Module -Name ModuleName -Exact
Install-Module -Name ModuleName -Force

The -Exact parameter looks for exact name matches only.

Use a file path instead of the module name:

Download the module NUPKG file locally first, then install from there.

Manually uninstall modules:

Removing already installed copies can resolve conflicts.

Get-InstalledModule 

Uninstall-Module ModuleName

Check for missing dependencies:

Use Get-Module -ListAvailable to see dependency information. Install any prerequisites.

Update the NuGet provider:

Install-PackageProvider -Name NuGet -Force

This can fix issues with the NuGet package manager.

With troubleshooting, you should be able to narrow down the specific reason gallery access fails on your system.

Summary

The “PowerShell Gallery is currently unavailable” message can be caused by a range of issues:

  • Network connectivity problems
  • Outdated or corrupted PowerShellGet module
  • Misconfigured system or security settings
  • Transient errors reaching the gallery website

Updating PowerShellGet, resetting its cache, and verifying network access will fix most cases. You can also circumvent gallery problems by installing modules from local files.

Following the troubleshooting steps here will help you get PowerShell gallery access restored quickly. Proper configuration ensures you can leverage the vast selection of PowerShell modules to help automate your Windows administration tasks.

Leave a Comment