Solution – 1
$URI = New-Object System.Uri("https://artifactory.example.com/artifactory/net-generic-local/APP/BF_2.0.zip")
$SOURCE = ".\BF_2.0.zip"
$AF_USER = "user"
$AF_PWD = ConvertTo-SecureString "password" -AsPlainText -Force
$CREDS = New-Object System.Management.Automation.PSCredential ($AF_USER, $AF_PWD)
Invoke-WebRequest -Uri $URI -InFile $SOURCE -Method Put -Credential $CREDS
Solution – 2
$SOURCE = ".\BF_2.0.zip"
$DESTINATION = "https://artifactory.example.com/artifactory/net-generic-local/APP/BF_2.0.zip"
$AF_USER ="user"
$AF_PWD ="password"
$WebClient = New-Object System.Net.WebClient
$WebClient.Credentials = New-Object System.Net.NetworkCredential($AF_USER, $AF_PWD)
$URI = New-Object System.Uri($DESTINATION)
$METHOD = "PUT"
$WebClient.UploadFile($URI, $METHOD, $SOURCE)
Solution – 3
$credential_bytes = [System.Text.Encoding]::UTF8.GetBytes($username + ":" + $api_token)
$credentials = [System.Convert]::ToBase64String($credential_bytes)
$credential_header = "Basic " + $credentials
Invoke-WebRequest -Uri $artifactory_dest_url -InFile "my_file.zip" -Method Put -Headers @{"Authorization"="$credential_header"}
Solution – 4
$SOURCE = ('D:\RefreshAutomationProd_bkp' + (get-date -Format yyyyMMdd) + '.zip')
echo "SOURCE : $SOURCE"
$DESTINATION = "http://172.26.10.46:8081/repository/RefreshAutomation/"+('RefreshAutomationProd_bkp' + (get-date -Format yyyyMMdd) + '.zip')
echo "DESTINATION : $DESTINATION"
$AF_USER ="admin"
$AF_PWD ="Admin@123"
$WebClient = New-Object System.Net.WebClient
$WebClient.Credentials = New-Object System.Net.NetworkCredential($AF_USER, $AF_PWD)
$URI = New-Object System.Uri($DESTINATION)
$METHOD = "PUT"
$WebClient.UploadFile($URI, $METHOD, $SOURCE)
Latest posts by Rajesh Kumar (see all)
- DevOps Foundation Certification - August 29, 2024
- SRE Foundation Certification - August 29, 2024
- Best Medical Tourism Company in the World - August 28, 2024