Last active
February 20, 2023 14:51
-
-
Save darrenjrobinson/3b5e9070cd8fe806cf06d16d8a38f1c4 to your computer and use it in GitHub Desktop.
Aggregate and IdentityNow Source with Disable Optimization. Associated blog post https://blog.darrenjrobinson.com/aggregating-sailpoint-identitynow-sources-via-api-with-powershell/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Your API Client ID | |
$clientID = 'yourClientID' | |
# Your API Client Secret | |
$clientSecret = 'yourSecret' | |
$Bytes = [System.Text.Encoding]::utf8.GetBytes("$($clientID):$($clientSecret)") | |
$encodedAuth = [Convert]::ToBase64String($Bytes) | |
# Your IdentityNow Tenant Name | |
$orgName = 'yourOrg' | |
# IdentityNow Admin User and PWD to connect with via oAuth | |
$adminUSR = [string]"yourAdminAccount".ToLower() | |
$adminPWDClear = 'yourAdminPWD' | |
# Encrypt creds from above. Requires the PSCX Module | |
$passwordHash = Get-Hash -Algorithm SHA256 -StringEncoding utf8 -InputObject ($($adminPWDClear) + (Get-Hash -Algorithm SHA256 -StringEncoding utf8 -InputObject ($adminUSR)).HashString.ToLower()) | |
$adminPWD = $passwordHash.ToString().ToLower() | |
# Base URI for Private API's (v1 APIs) | |
$baseURI = "https://$($orgName).identitynow.com" | |
# URI to get Token | |
$tokenURI = "https://$($orgName).identitynow.com/api/oauth/token?grant_type=password&username=$($adminUSR)&password=$($adminPWD)" | |
# Get Token | |
$token = Invoke-RestMethod -Method POST -Uri $tokenURI -Headers @{Authorization = "Basic $($encodedAuth)"} | |
if ($token ) { | |
try { | |
# Private API Sources API | |
$sourceID = 'sourceIDtoAggregate' | |
$baseURI = "https://$($orgName).identitynow.com/api/source/loadAccounts/$($sourceID)" | |
$headers = @{"Authorization" = "Bearer $($token.access_token)"} | |
$aggregate = Invoke-RestMethod -Method POST -uri $baseURI -Headers $headers -Body "disableOptimization=true" | |
$aggregate.task | |
} | |
catch { | |
write-host -foregroundcolor yellow "Well, that didn't work. Are you referecing the correct Source and Org?" | |
} | |
} | |
else { | |
write-host -foregroundcolor yellow "Well, that didn't work. Check your credentials, update and try again." | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment