Edit

Share via


Import-PSGetRepository

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

Syntax

Default (Default)

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.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False
Aliases:cf

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Force

Use the Force parameter to overwrite existing repositories.

Parameter properties

Type:SwitchParameter
Default value:False
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-WhatIf

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

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False
Aliases:wi

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

Outputs

Microsoft.PowerShell.PSResourceGet.UtilClasses.PSRepositoryInfo

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