How to work with PowerShell modules and Nuget repository in Artifactory?

JFrog Support
2018-01-29 14:24

Artifactory supports working with PowerShell modules with an Artifactory Nuget repository.

Find steps and commands to interact with Artifactory below:

1. Register the Nuget repository created in Artifactory:

Register-PSRepository -Name "<PS-REPOSITORY-NAME>" -SourceLocation "http://<ARTIFACTORY-IP:<PORT>/artifactory/api/nuget/<REPOSITORY-NAME>" -PublishLocation "http://<ARTIFACTORY-IP:<PORT>/artifactory/api/nuget/<REPOSITORY-NAME>" -InstallationPolicy Trusted

*  <PS-REPOSITORY-NAME> – The repository name that that will be created for the PowerShell client.

*  <REPOSITORY-NAME>      – The Nuget repository name in Artifactory.

 

2. Publish PowerShell module:

Publish-Module -Path "<PATH-TO-FILE>" -Repository <PS-REPOSITORY-NAME> -NuGetApiKey "<USER>:<API-KEY>"

 

3. Find modules:

Find-Module -Repository <PS-REPOSITORY-NAME>

 

4. Download module:

Save-Module -Repository <PS-REPOSITORY-NAME> -Name <MODULE-NAME> -Path <PATH-TO-FOLDER>

 

In case “Allow Anonymous Access” (in the “General Security Configuration” in Artifactory) is disabled, it is possible to use the -Credential flag to add the user’s credentials for authentication. For example:

 

Find-Module -Repository <PS-REPOSITORY-NAME> -Credential <USER>

 

Save-Module -Repository <PS-REPOSITORY-NAME> -Name <MODULE-NAME> -Path <PATH-TO-FOLDER> -Credential <USER>

 

*After executing the commands mentioned above (with the -Credential flag) you will be prompted to enter the user’s password.