Public/get-AllegisIDNAccount.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
function get-AllegisIDNAccount ($orgname, [alias(“id”)]$accountid, $sourceid, $IDNClientID, $IDNClientKey, $accesstoken){ if (!!$IDNClientID -and !!$IDNClientKey){ $header = get-AllegisIDNBasicAuthHeader -IDNClientID $IDNClientID -IDNClientKey $IDNClientKey }elseif(!!$accesstoken){ $header=get-AllegisIDNprivateHeader $accessToken } #if ($maxitems -gt 250){$loop=$true;$limit=250}else{$loop=$false;$limit=$maxitems} $limit=250 if (!$header){Write-Warning 'unable to create an auth header with provided parameters';return $null} if ($accountid -ne $null){ $url="https://$orgname.api.identitynow.com/v2/accounts/$($accountid)?org=$orgname" }else{ $url="https://$orgname.api.identitynow.com/v2/accounts/?sourceId=$sourceid&limit=$limit&org=$orgname" } $response=Invoke-WebRequest -UseBasicParsing -Uri $url -Headers $header -Method Get if ($response.Content.Length -ne 0){ $account=$response.Content | ConvertFrom-Json }else{$account=$null} return $account } |