Skip to content

Instantly share code, notes, and snippets.

@darrenjrobinson
Created October 17, 2019 03:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darrenjrobinson/b969890ba77237ac0a9816649f95d855 to your computer and use it in GitHub Desktop.
Save darrenjrobinson/b969890ba77237ac0a9816649f95d855 to your computer and use it in GitHub Desktop.
# IdentityNow Orgname
$orgName = "yourOrgName"
# IdentityNow Admin User
$adminUSR = [string]"YourAdminAccount".ToLower()
$adminPWDClear = 'yourAdminPassword'
# Generate the password hash
# Requires Get-Hash from PowerShell Community Extensions (PSCX) Module
# https://www.powershellgallery.com/packages/Pscx/3.2.2
$passwordHash = Get-Hash -Algorithm SHA256 -StringEncoding utf8 -InputObject ($($adminPWDClear) + (Get-Hash -Algorithm SHA256 -StringEncoding utf8 -InputObject ($adminUSR)).HashString.ToLower())
$adminPWD = $passwordHash.ToString().ToLower()
$adminPWD
# Customer-SB
$clientIDv3 = "ba38b166-5f24-4448-ac0b-yourClientID"
$clientSecretv3 = "770a71ae20c05301848d2222d8760fe0d9f632yourClientSecret"
# Basic Auth
$Bytesv3 = [System.Text.Encoding]::utf8.GetBytes("$($clientIDv3):$($clientSecretv3)")
$encodedAuthv3 = [Convert]::ToBase64String($Bytesv3)
$Headersv3 = @{Authorization = "Basic $($encodedAuthv3)"}
# Get v3 oAuth Token
# oAuth URI
$oAuthURI = "https://$($orgName).api.identitynow.com/oauth/token"
$v3Token = Invoke-RestMethod -Method Post -Uri "$($oAuthURI)?grant_type=password&username=$($adminUSR)&password=$($adminPWD)" -Headers $Headersv3 -SessionVariable IDNv3
if ($v3Token.access_token){
# Get Clusters
$clusters = Invoke-RestMethod -Method GET -Uri "https://$($orgName).identitynow.com/api/cluster/list" -Headers @{Authorization = "Bearer $($v3Token.access_token)"}
# Get Specific Cluster
$myCluster = $clusters | Select-Object | Where-Object {$_.description -eq "Australia East"}
if ($clusters){
write-host -ForegroundColor green "$($clusters.Count) IdentityNow VA Clusters found."
foreach ($cluster in $clusters){
write-host -ForegroundColor blue " $($cluster.description)"
foreach ($client in $cluster.clients) {
write-host -ForegroundColor Cyan " $($client.id) $($client.description)"
}
}
}
} else {
write-host -ForegroundColor Red "No Access Token obtained. Check your config settings."
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment