How to pass proxy while using download artifact command with winrm while windows host is using proxy

While using Download Artifact command[Service Types and Artifact Sources - Docs] from Harness using winrm, we do not provide a way to pass proxy details explicitly.

At deployment runtime, the Harness Delegate executes commands on the target host(s) to download the artifact directly to the target host(s). This is the process for file-based and metadata Artifact Sources. **The target host(s) must have network connectivity to the artifact server.**

So the command may fail if windows host require proxy to connect to artifact server and you might see below error in execution logs:

INFO   2022-07-16 02:24:39    Begin execution of command: Download Artifact
INFO   2022-07-16 02:24:39    Downloading artifact from ARTIFACTORY to %USERPROFILE%\path
INFO   2022-07-16 02:24:39    Initializing WinRM connection to ...
INFO   2022-07-16 02:24:40    Connected to
INFO   2022-07-16 02:24:40    Executing command ...
INFO   2022-07-16 02:24:40    
ERROR   2022-07-16 02:25:29    Invoke-WebRequest : Unable to connect to the remote server
ERROR   2022-07-16 02:25:29    At C:\<<path>>
ERROR   2022-07-16 02:25:29    p7gygytg.ps1:7 char:2
ERROR   2022-07-16 02:25:29    +  Invoke-WebRequest -Uri "https://artifactoryhost/ ...
ERROR   2022-07-16 02:25:29    +  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ERROR   2022-07-16 02:25:29        + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebExc 
ERROR   2022-07-16 02:25:29       eption
ERROR   2022-07-16 02:25:29        + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
INFO   2022-07-16 02:25:29    
INFO   2022-07-16 02:25:29    Command completed with ExitCode (1)
ERROR   2022-07-16 02:25:30    Command execution finished with status FAILURE

So in this case instead of using Harness download artifact step you can create a powershell script step and pass the proxy as below:

  1. Add System environment variable [ALL]
  1. Artifact download script
Invoke-WebRequest -Uri <articatoryurl> -Headers @{"sampleheader" = "value"} -OutFile "path" -Proxy "$env:HTTP_PROXY"

Microsoft doc reference- Invoke-WebRequest