PowerShell repositories

A reader on my blog asked if you can unregister the default PowerShell repository so you just use an internal repository.

First off – PSGallery is the default repository

PS> Get-PSRepository | Format-List

Name                      : PSGallery
SourceLocation            : https://www.powershellgallery.com/api/v2/
Trusted                   : False
Registered                : True
InstallationPolicy        : Untrusted
PackageManagementProvider : NuGet
PublishLocation           : https://www.powershellgallery.com/api/v2/package/
ScriptSourceLocation      : https://www.powershellgallery.com/api/v2/items/psscript/
ScriptPublishLocation     : https://www.powershellgallery.com/api/v2/package/
ProviderOptions           : {}

According to the documentation for Unregister-PSRepository you CAN’T unregister the default repository. In fact you can – the documentation appears to be incorrect

You can unregister PSGallery  with

Get-PSRepository -Name PSGallery | Unregister-PSRepository

NOTE You have to do this on a user by user basis

If you decide you need the default repository again then you can register it like this:

Register-PSRepository –Default

This entry was posted in PowerShell v5. Bookmark the permalink.

3 Responses to PowerShell repositories

  1. markrobertjohnson says:

    Hey Richard, that rocks, much appreciated! Totally counter-intuitive, how did you figure that out?

  2. markrobertjohnson says:

    Hmm, I just tried what you suggested “Get-PSRepository -Name PSGallery | Unregister-PSRepository”, but it still fails with the warning: “WARNING: The specified repository ‘PSGallery’ cannot be unregistered.”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s