external help file | Module Name | ms.custom | ms.date | online version | schema |
---|---|---|---|---|---|
Microsoft.PowerShell.PSResourceGet.dll-Help.xml |
Microsoft.PowerShell.PSResourceGet |
1.0.2 |
11/10/2023 |
2.0.0 |
Registers a repository for PowerShell resources.
Register-PSResourceRepository [-Name] <String> [-Uri] <String> [-Trusted] [-Priority <Int32>]
[-CredentialInfo <PSCredentialInfo>] [-PassThru] [-Force] [-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 PoshTestGallery
Name 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-PSResourceRepository
Name 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. You must have the Microsoft.PowerShell.SecretManagement module installed and have a registered vault containing the stored secret. The format of the secret must match the requirements of the repository.
$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 CredentialInfo
Name : PSGv3
Uri : https://www.powershellgallery.com/api/v3
Trusted : True
Priority : 50
CredentialInfo : Microsoft.PowerShell.PSResourceGet.UtilClasses.PSCredentialInfo
VaultName : SecretStore
SecretName : TestSecret
Credential :
A 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: False
Overwrites 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: False
Name 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: False
When 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: False
Specifies 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: False
When 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: False
Specifies 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: False
Specifies 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: False
Specifies 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: False
Prompts 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: False
Shows 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: False
This 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.