Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# 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
# Qantas-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
You can’t perform that action at this time.