Working with multiple PowerShellGet repositories

In http://blogs.msmvps.com/richardsiddaway/2015/01/04/creating-a-powershellget-repository/  I showed how to create a repository to use with PowerShellGet.  At the end of that article PowerShellGet would search all of the defined repositories for a module

£> Find-Module -Name Pester | Format-Table Version, Name, Repository -AutoSize

Version Name   Repository
——- —-   ———-
3.2.0   Pester PSGallery
3.2.0   Pester PowerShellModules

If you delete the Pester module and want to re-install it you need to specify the repository otherwise you get an error:

£> Install-Module -Name Pester -Verbose
VERBOSE: The -Repository parameter was not specified.  PowerShellGet will use all of the registered repositories.
VERBOSE: Getting the provider object for the OneGet Provider ‘NuGet’.
VERBOSE: The specified Location is ‘https://www.powershellgallery.com/api/v2/’ and OneGetProvider is ‘NuGet’.
VERBOSE: Getting the provider object for the OneGet Provider ‘NuGet’.
VERBOSE: The specified Location is ‘http://search.microsoft.com/default.aspx’ and OneGetProvider is ‘NuGet’.
VERBOSE: Getting the provider object for the OneGet Provider ‘NuGet’.
VERBOSE: The specified Location is ‘http://localhost:81/nuget/PowerShellModules’ and OneGetProvider is ‘NuGet’.
WARNING: ‘Pester’ matched module ‘Pester/3.2.0’ from provider: ‘PSModule’, repository
https://www.powershellgallery.com/api/v2/’
WARNING: ‘Pester’ matched module ‘Pester/3.2.0’ from provider: ‘PSModule’, repository
http://localhost:81/nuget/PowerShellModules’
OneGet\Install-Package : Unable to install, multiple modules matched ‘Pester’. Please specify a single -Repository.
At C:\Windows\system32\WindowsPowerShell\v1.0\Modules\PowerShellGet\PSGet.psm1:615 char:21
+             $null = OneGet\Install-Package @PSBoundParameters
+                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (Microsoft.Power….InstallPackage:InstallPackage) [Install-Package], E
   xception
    + FullyQualifiedErrorId : DisambiguateForInstall,Microsoft.PowerShell.OneGet.CmdLets.InstallPackage

£> Install-Module -Name Pester -Repository PowerShellModules -Verbose
VERBOSE: Repository details, Name = ‘PowerShellModules’, Location = ‘http://localhost:81/nuget/PowerShellModules’;
IsTrusted = ‘True’; IsRegistered = ‘True’.
VERBOSE: Repository details, Name = ‘PowerShellModules’, Location = ‘http://localhost:81/nuget/PowerShellModules’;
IsTrusted = ‘True’; IsRegistered = ‘True’.
VERBOSE: Using the specified source names : ‘PowerShellModules’.
VERBOSE: Getting the provider object for the OneGet Provider ‘NuGet’.
VERBOSE: The specified Location is ‘http://localhost:81/nuget/PowerShellModules’ and OneGetProvider is ‘NuGet’.
VERBOSE: In PSModule Provider – ‘Get-InstalledPackage’.
VERBOSE: Performing the operation “Install-Module” on target “Version ‘3.2.0’ of module ‘Pester'”.
VERBOSE: The specified Location is ‘NuGet’ and OneGetProvider is ‘NuGet’.
VERBOSE: Downloading module ‘Pester’ with version ‘3.2.0’ from the repository
http://localhost:81/nuget/PowerShellModules’.
VERBOSE: NuGet: Installing ‘Pester 3.2.0’.
VERBOSE: NuGet: Successfully installed ‘Pester 3.2.0’.
VERBOSE: Module ‘Pester’ was installed successfully.

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

2 Responses to Working with multiple PowerShellGet repositories

  1. markrobertjohnson says:

    Is there any way to make “Install-Package” not look at the default PSGallery at all? We have a ProGet server, and I would like to make that server our single source of packages, and not have to require specifying the repository name.

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