ARTIFACTORY: How to Register NuGet PackageSource and PSRepository with Artifactory
In order to register Artifactory as a PSRepository, we would need to use Register-PackageSource and Register-PSRepository commands.
The below example demonstrates how to register Artifactory as a PSRepository, find modules, and download using Powershell.
0. Unregister any unwanted PSRepositories
> Unregister-PSRepository -Name "old-repo”
1. Register PackageSource
> Register-PackageSource -Name "test" -Location "http://[your_artifactory_url]:[port]/artifactory/api/nuget/[your-nuget-repo-name]" -ProviderName NuGet
2. Register PSRepository
> Register-PSRepository -Name "test" -SourceLocation "http://[your_artifactory_url]:[port]/artifactory/api/nuget/[your-nuget-repo-name]" -InstallationPolicy Trusted -Credential [your_username] -Verbose
3. Search for modules
> Find-Module -Repository "test" -Credential [your_username] -Verbose
4. Download the file
> Save-Module -Repository "test" -Name [package-name] -Path C:\Users\user\Downloads\ -Verbose