| description | This article demonstrates how to use SecretStore credentials with an Artifactory repository. |
|---|---|
| ms.date | 04/21/2026 |
| title | How to add credentials to repositories in Microsoft.PowerShell.PSResourceGet |
Microsoft.PowerShell.PSResourceGet allows you to register private repositories that contain installable PSResource packages. Typically, private repositories require you to have credentials to access them. JFrog Artifactory is a service that allows you to create private NuGet repositories. This article demonstrates how to use SecretStore credentials with an Artifactory repository.
- Set up a SecretManagement vault
- Create a credential to be used with Artifactory
Note
This example uses SecretStore, but you can use any SecretManagement extension vault and with any repository.
Use Get-SecretInfo to verify that the vault contains the credential you need.
Get-SecretInfoName Type VaultName
---- ---- ---------
JFrogCred PSCredential SecretStore
For more information about SecretManagement, see Overview of the SecretManagement and SecretStore modules.
Once you have a store credential, you need to add it to the registered repository. Create a
PSCredentialInfo object that references the store credential. You can register a new
PSResourceRepository or add the credential to an existing one using the
Set-PSResourceRepository cmdlet. This example shows how to register a new repository.
$registerPSResourceRepositorySplat = @{
Name = 'artifactory'
Uri = 'https://myaccount.jfrog.io/artifactory/api/nuget/v3/myrepository'
Trusted = $true
CredentialInfo = [Microsoft.PowerShell.PSResourceGet.UtilClasses.PSCredentialInfo]::new(
'SecretStore', 'JFrogCred')
}
Register-PSResourceRepository @registerPSResourceRepositorySplatRun Get-PSResourceRepository to see the registered repositories.
PS C:\Users > Get-PSResourceRepositoryName Uri Trusted Priority
---- --- ------- --------
artifactory https://myaccount.jfrog.io/artifactory/api/nuget/v3/myrepository True 50
PSGallery https://www.powershellgallery.com/api/v2 False 50
To publish resources to a secured repository, you must provide the credential you configured. This
example shows how to publish a resource to the artifactory repository using your stored credential.
Publish-PSResource -Path .\Get-Hello\ -Repository artifactory -ApiKey (Get-Secret JFrogPublish)PowerShellGet reuses the credential for subsequent commands that target the same repository. The following examples show how to find and install a resource. Notice that the credential isn't required.
Find-PSResource -Name Get-Hello -Repository artifactoryName Version Prerelease Repository Description
---- ------- ---------- ---------- -----------
Get-Hello 0.0.2.0 artifactory test module
PS C:\Users> Install-PSResource Get-Hello