Testing the Ivanti Endpoint Manager Distribution API

Setup Commander uses the Distribution API which is available in Ivanti Endpoint Manager 2017.3 Update 3 and up.

This API and its documentation can be accessed on the EPM server using this URL: https://localhost/DistributionApi/Swagger/ui/index

If you can’t connect Ivanti Package Studio to your EPM environment successfully after using the tips and tricks provided in Ivanti Package Studio, please use this PowerShell script against your environment. Update the script to reflect your environment details first.

If this script doesn’t finish successfully, contact Ivanti support to
follow up with you.

 

<SCRIPT>

# Variables
$username = “administrator”
$password = “P@ssw0rd”
$clientid = “SetupCommander”
$clientsecret = “secret”
$baseurl = “https://192.168.1.100/my.identityserver/identity/connect/token”
$returnCodeTemplatesUrl = “https://192.168.1.100/distributionapi/api/v1/ReturnCodeTemplates”

# Set the url
$data = “grant_type=password&client_id=” + $clientid + “&client_secret=” + $clientsecret + “&username=” + $username + “&scope=openid&password=” + $password
Write-Host($url)

# Authenticate
$webclient = new-object System.Net.WebClient
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
$authResult = $webclient.UploadString($baseurl, $data)

# Get the access_token
$authResultJson = $authResult | ConvertFrom-Json
$accesstoken = $authResultJson.access_token

# Get the ReturnCodeTemplates
$req = [System.Net.WebRequest]::Create($returnCodeTemplatesUrl)
$req.Headers.Add(“Authorization”, “Bearer ” + $accesstoken)
$req.Method = “GET”
$resp = $req.GetResponse()
$reqstream = $resp.GetResponseStream()
$sr = new-object System.IO.StreamReader $reqstream
$result = $sr.ReadToEnd()
write-host $result

</SCRIPT>

About the author

Leave a Reply