In this post – https://richardspowershellblog.wordpress.com/2016/09/17/powershell-repositories/ – I stated that you could unregister the default PowerShell repository. I also said that the statement in the documentation for Unregister-PSrepository that you couldn’t unregister PSGallery was incorrect.
A couple of readers have left comments stating that they tried it and got an error message stating that PSGallery can’t be unregistered.
I did my first test on Windows 10 latest preview build – build 14926
PS> $PSVersionTable
Name Value
—- —–
PSVersion 5.1.14926.1000
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
BuildVersion 10.0.14926.1000
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
I’ve just test on Windows Server 2016 TP5
PS C:\Windows\system32> $PSVersionTable
Name Value
—- —–
PSVersion 5.1.14300.1000
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
CLRVersion 4.0.30319.42000
BuildVersion 10.0.14300.1000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
The version of PowerShell 5.1 on Server 2016 TP5 doesn’t have the –Default parameter on Register-PSrepositiry but this works
Register-PSRepository -Name PSGallery -SourceLocation https://www.powershellgallery.com/api/v2/
It appears that the ability to unregister the default repository and then re-register it is an evolving feature in PowerShell 5.1
Thanks Richard for the thorough detail on this behavior. I wonder what can be done for those of us that are stuck with 5.0.10586.117 for the foreseeable future? Do you think that default configuration is stored in a file or registry key somewhere that I could manually modify (yes, it is dirty, but what choice do I have?)
Reblogged this on Code and commented:
Thank to Richard for his deep research on this issue …
I found a solution for those of us running 5.0.10586.117, see the solution here: https://markrobertjohnson.wordpress.com/2016/10/12/unregistering-the-default-repository-ps-version-dependent/
Well, not really the solution to unregistering the default gallery (Still had issue with that, even modifying the XML config directly), but at least allows for modifying the default URLs…