Skip to content

Instantly share code, notes, and snippets.

@darrenjrobinson
Last active September 12, 2018 05:14
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/2bb57df933acb8e8e6b898039cd67539 to your computer and use it in GitHub Desktop.
Save darrenjrobinson/2bb57df933acb8e8e6b898039cd67539 to your computer and use it in GitHub Desktop.
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