Instantly share code, notes, and snippets.

Embed
What would you like to do?
Create IdentityNow Account 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 = 'yourTenantOrgName'
# 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 = 'yourIdentityNowSourceID'
$baseURI = "https://$($orgName).api.identitynow.com"
# Create User Details
$body = @{"id" = 'rick.sanchez';
"name" = 'rick.sanchez';
"givenName" = 'Rick';
"familyName" = 'Sanchez';
"displayName" = 'Rick Sanchez';
"e-mail" = 'rick@councilofricks.com'
}
$body = $body | Convertto-json
$headers = @{'Content-Type' = 'application/json';
Authorization = "Basic $($encodedAuth)";
}
try {
Invoke-RestMethod -Method POST -Uri "$($baseURI)/v2/accounts?sourceId=$($sourceID)&org=$($orgName)" -Headers $headers -Body $body
}
catch {
write-host -ForegroundColor 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