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
Hey Richard, that rocks, much appreciated! Totally counter-intuitive, how did you figure that out?
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.”
It appears to be PowerShell version dependent