Import-PSGetRepository

Finds the repositories registered with PowerShellGet and registers them for PSResourceGet.

Syntax

Import-PSGetRepository
      [-Force]
      [-WhatIf]
      [-Confirm]
      [<CommonParameters>]

Description

This cmdlet finds the NuGet repositories registered with PowerShellGet v2 and registers them for PSResourceGet. PowerShellGet v2 has a provider model that allows you to register repositories that use different provider protocols. PSResourceGet only supports NuGet repositories, so this cmdlet only imports NuGet repositories.

The PSGallery repository is registered by default. This cmdlet doesn't import the PSGallery repository from PowerShellGet v2. If you need to reregister the PSGallery repository, use the Register-PSResourceRepository cmdlet with the PSGallery parameter.

Examples

Example 1 - Show the NuGet repositories registered with PowerShellGet v2

This example uses the Verbose and WhatIf parameters to show the NuGet repositories registered with PowerShell v2.

Import-PSGetRepository -Verbose -WhatIf

VERBOSE: Found 3 registered PowerShellGet repositories.
VERBOSE: Selected 2 NuGet repositories.
What if: Registering LocalGallery at E:\LocalGallery\ -Trusted:$True -Force:$False.
What if: Registering PrivateRepo at https://PrivateRepo:44370/nuget -Trusted:$True -Force:$False.

The cmdlet found three repositories registered with PowerShellGet v2, but will only import two of them. In this case, the third repository is the default PSGallery repository.

Example 2 - Register the NuGet repositories registered with PowerShellGet v2

Import-PSGetRepository

Name         Uri                             Trusted Priority
----         ---                             ------- --------
LocalGallery file:///E:/LocalGallery/        True    50
PrivateRepo  https://PrivateRepo:44370/nuget True    50

Example 3 - Overwrite existing repositories

By default, the cmdlet doesn't import PowerShellGet v2 repositories that have the same name as a registered PSResourceGet repository. Use the Force parameter to overwrite existing repositories.

Import-PSGetRepository

WARNING: Adding to repository store failed: The PSResource Repository 'LocalGallery' already exists.
WARNING: Use the -Force switch to overwrite existing repositories.
WARNING: Adding to repository store failed: The PSResource Repository 'PrivateRepo' already exists.
WARNING: Use the -Force switch to overwrite existing repositories.

Import-PSGetRepository -Force

Name         Uri                             Trusted Priority
----         ---                             ------- --------
LocalGallery file:///E:/LocalGallery/        True    50
PrivateRepo  https://PrivateRepo:44370/nuget True    50

Parameters

-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Force

Use the Force parameter to overwrite existing repositories.

Type:SwitchParameter
Position:Named
Default value:False
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet isn't run.

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

Outputs

Microsoft.PowerShell.PSResourceGet.UtilClasses.PSRepositoryInfo

The cmdlet returns a PSRepositoryInfo object for each NuGet repository registered with PowerShellGet v2.