If you're using a NuGet repository, Artifactory provides you with the ability to work with PowerShell modules.
First, you can set up a PowerShell Gallery Remote Repository using these settings:
[ URL: https://www.powershellgallery.com/ - Use the default NuGet Settings]
To configure the PowerShell Client, you can follow these steps 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> is the repository name that that will be created for the PowerShell client and <REPOSITORY-NAME> is the name of the NuGet repository in Artifactory.
If Allow Anonymous Access (in Artifactory’s General Security Configuration) is disabled, you can use the credential flag to add a user’s credentials for authentication. For example:
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>" -Credential <USERNAME> -InstallationPolicy Trusted
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>
Note:
If Allow Anonymous Access (in Artifactory’s General Security Configuration) is disabled, you can use the credential flag to add a 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 these commands (with the credential flag), you’ll be prompted to enter the user’s password.