Here’s the powershell code.
#Parameters must be declared at the start of the script. Param( [Parameter(Mandatory=$true)][string]$usr, [Parameter(Mandatory=$true)][string]$pwd, [Parameter(Mandatory=$true)][ipaddress]$src, [Parameter(Mandatory=$true)][ipaddress]$dst, [Parameter(Mandatory=$false)][string]$svc = 'any' ) add-type @" using System.Net; using System.Security.Cryptography.X509Certificates; public class TrustAllCertsPolicy : ICertificatePolicy { public bool CheckValidationResult( ServicePoint srvPoint, X509Certificate certificate, WebRequest request, int certificateProblem) { return true; } } "@ [System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy $cred = "${usr}:${pwd}" $bytes = [System.Text.Encoding]::ASCII.GetBytes($cred) #header has to be base64 encoding $base64 = [System.Convert]::ToBase64String($bytes) $basicAuthValue = "Basic $base64" $headers = @{ Authorization = $basicAuthValue } $date = Get-Date try { Invoke-RestMethod -Uri "https://tufin_hostname/securetrack/api/topology/path_image?src=$($src)&dst=$($dst)&service=$($svc)" -Method Get -ContentType 'application/xml' -Headers $headers -OutFile "$env:USERPROFILE\path_image_$($date.ToString('ddMMyy-HHmm')).png" } catch { $Error[0].ErrorDetails.Message }
Wow… I was brainstorming on this but you were thinking ahead of me.
Thanks for making my task easy..
Glad this post is of use to you.