Download folder from the Artifactory repo using Powershell

Viewed 2372

I am using the following code to download files from Jfrog Artifactory using Powershell. It's working perfectly. I now have a repository on Artifactory that has couple of recursive folders with files. So I need to download all contents of that repository. Can anyone suggest What I need to change with the following code:

#example Artifactory url
 $artifactory_url = "https://artifactory.company.com/artifactory/"
 #example Artifactory Key
 $ArtifactoryKey = "AKCp2VpEfLuMVkxpmH9rSiZT3RPoWCucL8kEiq4SjbEuuuCFdNf5t5E6dom32TCE3efy2RCyg" 

 $wc = New-Object System.Net.WebClient
 $wc.Headers.Add("X-JFrog-Art-Api", $ArtifactoryKey)
 $files = @("test1.zip", "test.zip") 
 try {
   foreach($file in $files) {
     $wc.DownloadFile("$artifactory_url/$file", "D:\download\$file")
   }
 }
 catch {
    $Host.UI.WriteErrorLine("Error while Trying to download Artifacts.")
    $Host.UI.WriteErrorLine($_.Exception.Message)
    exit
 }
1 Answers

To download the entire folder under a repository you can utilize the JFrog CLI. First, configure the Artifactory with the JFrog CLI and download the entire folder as below,

$ jfrog rt dl "my-local-repo/*.jar" all-my-frogs/
Related