Instantly share code, notes, and snippets.

Embed
What would you like to do?
Bulk Update SailPoint IdentityNow Entities via API and PowerShell. Assoicated Blog https://blog.darrenjrobinson.com/lifecycle-management-of-identities-in-sailpoint-identitynow-via-api-and-powershell/
# Your API Client ID
$clientID = 'yourClientID'
# Your API Client Secret
$clientSecret = 'yourClientSecret'
$Bytes = [System.Text.Encoding]::utf8.GetBytes("$($clientID):$($clientSecret)")
$encodedAuth = [Convert]::ToBase64String($Bytes)
# Your IdentityNow Tenant Name
$orgName = 'yourOrgName'
# SourceID of the Flat File Source to create the new account against.
# Navigate to the Source in the IdentityNow Portal and get the SourceID from the URL
# https://<orgName>.identitynow.com/ui/admin#admin:connections:sources
$sourceID = 'yourSourceID'
$searchLimit = '1000'
# Query (SOURCE NAME)
$query = '@accounts.source.name = "External Entities"'
# URI's
$URI = "https://$($org).api.identitynow.com/v2/search/identities?"
$updateBaseURI = "https://$($org).api.identitynow.com/v2/accounts/"
# https://tenant.api.identitynow.com/v2/accounts/2c91808365bd1f010165caf761625bcd?org=orgName
# Perform Search
$searchResults = Invoke-RestMethod -Method Get -Uri "$($URI)limit=$($searchLimit)&query=$($query)" -Headers @{Authorization = "Basic $($encodedAuth)" }
write-host "$($searchResults.Count) found"
foreach ($identity in $searchResults) {
$id = $null
Write-host "$($identity.displayName)"
foreach ($account in $identity.accounts) {
If ($account.source.name.Equals("External Entities")) {
$id = $account.id
}
}
if ($id) {
$updateURI = "$updateBaseURI$($id)?org=$($orgName)"
# Update 'country' attribute
$body = @{
"country" = "Australia"
}
$body = $body | ConvertTo-Json
# Update
try {
Invoke-RestMethod -Uri $updateURI -Method Patch -Body $body -Headers @{Authorization = "Basic $($encodedAuth)"; 'Content-Type' = 'application/json' }
}
catch {
write-host -forgroundcolor yellow "Well, that didn't work. Check your script"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment