# Update-Module – PackageManagement\Install-Package : Unable to find repository

I was installing newest version of my PSWinDocumentation module on Windows 2016 when I noticed I can’t really get anything…

blog

19 Oct 2018 de

![Update-Module – PackageManagement\Install-Package : Unable to find repository](/wp-content/uploads/2018/10/img_5bc9fe34bb6bb.png)

[Bilder ansehen (5)](#pf-content-image-1-0)

I was installing newest version of my **PSWinDocumentation** module on Windows 2016 when I noticed I can't really get anything to update. I was getting message as below which seemed a bit weird because it was working few minutes ago and only thing I did is to change trust for PowerShellGallery.

```powershell
Set-PSRepository -Name 'PSGallery' -InstallationPolicy Trusted
```

### 💡 What isn't working?

> PackageManagement\Install-Package : Unable to find repository ‘[https://www.powershellgallery.com/api/v2/](https://www.powershellgallery.com/api/v2/)'. Use Get-PSRepository to see all available repositories. At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.0.1\PSModule.psm1:13000 char:20
> 
> - … $sid = PackageManagement\Install-Package @PSBoundParameters
> - CategoryInfo : ObjectNotFound: (Microsoft.Power….InstallPackage:InstallPackage) [Install-Package], Exception
> - FullyQualifiedErrorId : SourceNotFound,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

[!\[PowerShell console showing Install-Package failing with the unable to find repository error\](/wp-content/uploads/2018/10/img_5bc9fe34bb6bb.png)](/wp-content/uploads/2018/10/img_5bc9fe34bb6bb.png)

```powershell
PackageManagement\Install-Package : Unable to find repository 'https://www.powershellgallery.com/api/v2/'. Use Get-PSRepository to see all available repositories.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.0.1\PSModule.psm1:13000 char:20
+ ...           $sid = PackageManagement\Install-Package @PSBoundParameters
+                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Exception
    + FullyQualifiedErrorId : SourceNotFound,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage
```

Trying suggested way I've verified that PSGallery settings are actually correct and as expected.

[!\[PowerShellGet repository settings showing PSGallery registered as a trusted source\](/wp-content/uploads/2018/10/img_5bc9feccc6d1f.png)](/wp-content/uploads/2018/10/img_5bc9feccc6d1f.png)

What was even weirder **Install-Module **worked as designed.

```powershell
PS C:\Windows\system32> update-module pswindocumentation
PackageManagement\Install-Package : Unable to find repository 'https://www.powershellgallery.com/api/v2/'. Use
Get-PSRepository to see all available repositories.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.0.1\PSModule.psm1:13000 char:20
+ ...           $sid = PackageManagement\Install-Package @PSBoundParameters
+                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Ex
   ception
    + FullyQualifiedErrorId : SourceNotFound,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

PS C:\Windows\system32> install-module pswindocumentation
PS C:\Windows\system32> install-module pswindocumentation -force
PS C:\Windows\system32>
```

[!\[PowerShell console where Install-Module succeeds even though Install-Package cannot find the repository\](/wp-content/uploads/2018/10/img_5bca058f39cae.png)](/wp-content/uploads/2018/10/img_5bca058f39cae.png)

### 💡 How can I fix it?

While I've finally fixed this issue I'm not sure which of the steps I did had the right impact. Therefore… worst case scenario … do it all.

- 💡 Unregister and Register PowerShell Gallery

This actually unregisters **PowerShellGallery** and registers it back. This should work when the bug in **PowerShellGet** will be fixed.

```powershell
Unregister-PSRepository -Name 'PSGallery'
Register-PSRepository -Default
```

- 💡 Unregister and Register PowerShell Gallery as an alternative

This actually unregisters **PowerShellGallery** and registers it back but as an alternative source. It adds missing **slash **so make sure you add it with **[https://www.powershellgallery.com/api/v2/](https://www.powershellgallery.com/api/v2/), **not **[https://www.powershellgallery.com/api/v2**](https://www.powershellgallery.com/api/v2**)

```powershell
Unregister-PSRepository -Name 'PSGallery'
Register-PSRepository -Name 'PSGallery-Alternative' -SourceLocation 'https://www.powershellgallery.com/api/v2/' -InstallationPolicy Trusted
```

This issue can be visible on the screen below. First, we have a working PowerShell Repository, then it's unregistered and when you register it back it's missing slash.

[!\[Repository registration example showing the source location losing the trailing slash after re-registering PSGallery\](/wp-content/uploads/2019/01/img_5c3fb0cb626df.png)](/wp-content/uploads/2019/01/img_5c3fb0cb626df.png)

- 💡 Uninstall **PowerShellGet** module, install it back

[!\[PowerShell commands unregistering and registering the PSGallery repository to restore Install-Package\](/wp-content/uploads/2018/10/img_5bca09573b9d8.png)](/wp-content/uploads/2018/10/img_5bca09573b9d8.png)

```powershell
Uninstall-Module PowerShellGet
Install-Module PowerShellGet -Force
```

This is my top choice to fix this. I actually did this couple of times with closing **PowerShell** window and without getting always same message. Finally I went for reboot. Which makes sense because the very package responsible for updating was busy updating.

- 💡 Finally **Reboot**

As with any critical system problems a reboot is good way to have a clean start. Some settings can't update while system is running.

## Zugehörige Projekte

Projekte, die zu Tags, Kategorien und Inhalt dieses Beitrags passen.

[Alle Projekte](/de/projekte/)

Projekte werden abgeglichen...

[Zurück zum Blog](/blog)

## Ähnliche Beiträge

- [Active Directory – How to track down why and where the user account was locked out](/de/blog/active-directory-how-to-track-down-why-and-where-the-user-account-was-locked-out/)
- [PowerBGInfo 2.x: support-ready Windows backgrounds from PowerShell](/de/blog/powerbginfo-support-ready-windows-backgrounds/)
- [Track Ubiquiti Unifi Stock, and get notified of changes](/de/blog/simplify-notifications-about-ubiquiti-unifi-stock/)

<!-- PowerForge markdown artifact sha256:122DF0F3471F0BECFF5434490637A026066CCB73B945322727700B405C226AFA -->
