Last active
June 14, 2022 01:10
-
-
Save guitarrapc/79d31b8cd02649075642b77c4ae796ab to your computer and use it in GitHub Desktop.
Whom you miss PSGallery with Get-PSRepository!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Register-PSRepository -Name PSGallery -SourceLocation https://www.powershellgallery.com/api/v2/ -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/ -InstallationPolicy Trusted -PackageManagementProvider NuGet |
Register-PSRepository -Default with WMF 5.1 it seems
PS C:\> Register-PSRepository -Name PSGallery -SourceLocation https://www.powershellgallery.com/api/v2/ -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/ -InstallationPolicy Trusted -PackageManagementProvider NuGet
Register-PSRepository : Use 'Register-PSRepository -Default' to register the PSGallery repository.
At line:1 char:1
+ Register-PSRepository -Name PSGallery -SourceLocation https://www.pow ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (PSGallery:String) [Register-PSRepository], ArgumentException
+ FullyQualifiedErrorId : UseDefaultParameterSetOnRegisterPSRepository,Register-PSRepository
PS C:\> Register-PSRepository -Default
PackageManagement\Register-PackageSource : Module Repository 'PSGallery' exists.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:4211 char:17
+ ... $null = PackageManagement\Register-PackageSource @PSBoundParamete ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceExists: (Microsoft.Power...erPackageSource:RegisterPackageSource) [Register-PackageSource], Exception
+ FullyQualifiedErrorId : PackageSourceExists,Microsoft.PowerShell.PackageManagement.Cmdlets.RegisterPackageSource
PS C:\> Get-PSRepository
Name InstallationPolicy SourceLocation
---- ------------------ --------------
PSGallery Untrusted https://www.powershellgallery.com/api/v2
PowerShell still makes life too hard.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This helped me set things up on a Windows Server 2012 R2 system, running PowerShell v4.0.
Installed "PackageManagement PowerShell Modules Preview - March 2016"
Ran the following command you provided;
Register-PSRepository -Name PSGallery
-SourceLocation https://www.powershellgallery.com/api/v2/
-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/
-InstallationPolicy Trusted -PackageManagementProvider NuGet
Save-Module -Name SpeculationControl -Path C:\Path\To\PowerShell\Modules\