| external help file | Microsoft.PowerShell.PSResourceGet.dll-Help.xml |
|---|---|
| Module Name | Microsoft.PowerShell.PSResourceGet |
| ms.custom | 1.2.0-p5 |
| ms.date | 12/10/2025 |
| online version | https://learn.microsoft.com/powershell/module/microsoft.powershell.psresourceget/register-psresourcerepository?view=powershellget-3.x&WT.mc_id=ps-gethelp |
| schema | 2.0.0 |
Registers a repository for PowerShell resources.
Register-PSResourceRepository [-Name] <String> [-Uri] <String> [-Trusted] [-Priority <Int32>]
[-ApiVersion <APIVersion>] [-CredentialInfo <PSCredentialInfo>] [-PassThru] [-Force]
[-CredentialProvider <CredentialProvider>] [-WhatIf] [-Confirm] [<CommonParameters>]
Register-PSResourceRepository [-PSGallery] [-Trusted] [-Priority <Int32>] [-PassThru] [-Force]
[-WhatIf] [-Confirm] [<CommonParameters>]
Register-PSResourceRepository -Repository <Hashtable[]> [-PassThru] [-Force] [-WhatIf] [-Confirm]
[<CommonParameters>]
The cmdlet registers a NuGet repository containing PowerShell resources.
This example registers the repository with the Name of PoshTestGallery.
Register-PSResourceRepository -Name PoshTestGallery -Uri 'https://www.poshtestgallery.com/api/v2'
Get-PSResourceRepository -Name PoshTestGalleryName Uri Trusted Priority
---- --- ------- --------
PoshTestGallery https://www.poshtestgallery.com/api/v2 False 50
This example registers the default PSGallery repository. Unlike the previous example, we can't use
the Name and Uri parameters to register the PSGallery repository. The PSGallery
repository is registered by default but can be removed. Use this command to restore the default
registration.
Register-PSResourceRepository -PSGallery
Get-PSResourceRepository -Name 'PSGallery'Name Uri Trusted Priority
---- --- ------- --------
PSGallery https://www.powershellgallery.com/api/v2 False 50
This example registers multiple repositories at once. To do so, we use the Repository parameter and provide an array of hashtables. Each hashtable can only have keys associated with parameters for the NameParameterSet or the PSGalleryParameterSet.
$arrayOfHashtables = @{
Name = 'Local'
Uri = 'D:/PSRepoLocal/'
Trusted = $true
Priority = 20
},
@{
Name = 'PSGv3'
Uri = 'https://www.powershellgallery.com/api/v3'
Trusted = $true
Priority = 50
},
@{
PSGallery = $true
Trusted = $true
Priority = 10
}
Register-PSResourceRepository -Repository $arrayOfHashtables
Get-PSResourceRepositoryName Uri Trusted Priority
---- --- ------- --------
PSGallery https://www.powershellgallery.com/api/v2 True 10
Local file:///D:/PSRepoLocal/ True 20
PSGv3 https://www.powershellgallery.com/api/v3 True 50
This example registers a repository with credential information to be retrieved from a registered SecretManagement vault, where SecretStore is the name of the vault and TestSecret is the name of the stored secret.
You must have the Microsoft.PowerShell.SecretManagement module installed, have a registered
vault, and stored a secret within it. If setup correctly, the command
Get-SecretInfo -Name 'TestSecret' would return the secret.
The format of the secret must match the requirements of the repository. In some instances,
TestSecret might need storing as a PSCredential object with a username and password or token.
In others it may need storing as a SecureString representing just the token.
$parameters = @{
Name = 'PSGv3'
Uri = 'https://www.powershellgallery.com/api/v3'
Trusted = $true
Priority = 50
CredentialInfo = [Microsoft.PowerShell.PSResourceGet.UtilClasses.PSCredentialInfo]::new(
'SecretStore', 'TestSecret')
}
Register-PSResourceRepository @parameters
Get-PSResourceRepository | Select-Object * -ExpandProperty CredentialInfoName : PSGv3
Uri : https://www.powershellgallery.com/api/v3
Trusted : True
Priority : 50
CredentialInfo : Microsoft.PowerShell.PSResourceGet.UtilClasses.PSCredentialInfo
VaultName : SecretStore
SecretName : TestSecret
Credential :
Specifies the API version used by the repository. Valid values are:
V2- uses the NuGet V2 APIV3- uses the NuGet V3 APIContainerRegistry- used for Azure Container RegistryLocal- use this for file system based repositoriesNugetServer- use this for NuGet.Server based repositories
The Register-PSResourceRepository cmdlet should automatically detect the API version. This
parameter allows you to change the API version after you have registered a repository.
Type: Microsoft.PowerShell.PSResourceGet.UtilClasses.PSRepositoryInfo+APIVersion
Parameter Sets: NameParameterSet
Aliases:
Accepted values: V2, V3, Local, NugetServer, ContainerRegistry
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseA PSCredentialInfo object that includes the name of a vault and a secret that's stored in a Microsoft.PowerShell.SecretManagement store.
Type: Microsoft.PowerShell.PSResourceGet.UtilClasses.PSCredentialInfo
Parameter Sets: NameParameterSet
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseThis is a dynamic parameter that specifies the credential provider to use for the repository. This parameter is only available when the repository being registered is an Azure Artifacts feed. Valid values are:
None- No credential provider definedAzArtifacts- Use the Azure Artifacts Credential Provider
If you don't use this parameter, the default value is None. If the repository URL contains
pkgs.dev.azure.com or pkgs.visualstudio.com, the command automatically registers the repository
with the CredentialProvider property set to AzArtifacts.
Type: Microsoft.PowerShell.PSResourceGet.UtilClasses.CredentialProviderType
Parameter Sets: NameParameterSet
Accepted values: None, AzArtifacts
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseOverwrites a repository if it already exists.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: FalseName of the repository to be registered. Can't be PSGallery.
Type: System.String
Parameter Sets: NameParameterSet
Aliases:
Required: True
Position: 0
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseWhen specified, displays the successfully registered repository and its information.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies the priority ranking of the repository. Valid priority values range from 0 to 100. Lower
values have a higher priority ranking. The default value is 50.
Repositories are sorted by priority then by name. When searching for resources across multiple repositories, the PSResourceGet cmdlets search the repositories using this sort order and return the first match found.
Type: System.Int32
Parameter Sets: NameParameterSet, PSGalleryParameterSet
Aliases:
Required: False
Position: Named
Default value: 50
Accept pipeline input: False
Accept wildcard characters: FalseWhen specified, registers PSGallery repository.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: PSGalleryParameterSet
Aliases:
Required: True
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies an array of hashtables that contain repository information. Use this parameter to register multiple repositories at once. Each hashtable can only have keys associated with parameters for the NameParameterSet or the PSGalleryParameterSet.
Type: System.Collections.Hashtable[]
Parameter Sets: RepositoriesParameterSet
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies whether the repository should be trusted.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: NameParameterSet, PSGalleryParameterSet
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies the location of the repository to be registered. The value must use one of the following URI schemas:
https://http://ftp://file://
Type: System.String
Parameter Sets: NameParameterSet
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalsePrompts you for confirmation before running the cmdlet.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: cf
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: FalseShows what would happen if the cmdlet runs. The cmdlet isn't run.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: wi
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: FalseThis cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
By default, the cmdlet produces no output. When you use the PassThru parameter, the cmdlet returns a PSRepositoryInfo object.
Repositories are unique by Name. Attempting to register a repository with same name results in an error.