[powershell]Get the verifier topology from Tufin SecureChange

There is a href in /securechangeworkflow/api/securechange/tickets/$ticket_id/steps for calling the topology map.

Consider this script, supposed the previous script has passed the request successfully, that script passed the ticket id to this script.

#ignore certificate validation
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
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12


$pwd = Obfuscate_Password($usr)
$cred = "${usr}:${pwd}"
$bytes = [System.Text.Encoding]::ASCII.GetBytes($cred)
$base64 = [System.Convert]::ToBase64String($bytes)
$basicAuthValue = "Basic $base64"
$headers = @{ Authorization = $basicAuthValue }

try {
  [xml]$response_verifier = Invoke-RestMethod -Uri "https://tufin_address/securechangeworkflow/api/securechange/tickets/$ticketID/steps" -Method Get -Headers $headers

catch {
$verifier_maps = $response_verifier.steps.step.tasks.task.fields.field.access_request.verifier_result.result.href
foreach($verifier_map in $verifier_maps)
    Invoke-RestMethod -Uri "$verifier_map/topology_map" -Method Get -Headers $headers -OutFile "map$i.png"
    $i += 1

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s