Public/update-AllegisIDNAccount.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
function update-AllegisIDNAccount ($orgname, $sourceid, $IDNClientID, $IDNClientKey, $accesstoken, $userdetails, $accountid){ if (!!$IDNClientID -and !!$IDNClientKey){ $header = get-AllegisIDNBasicAuthHeader -IDNClientID $IDNClientID -IDNClientKey $IDNClientKey }elseif(!!$accesstoken){ $header=get-AllegisIDNprivateHeader $accessToken } $schema=get-AllegisIDNsourceSchema -orgName $orgname -sourceid $sourceid -accessToken $accesstoken $account=@() foreach($attr in $schema[0].fields.name) { if ($account.count -eq 0){ $account=[pscustomobject]@{"$attr"="$($userdetails.$attr)"} }else{ $account | Add-Member -NotePropertyName "$attr" -NotePropertyValue "$($userdetails.$attr)" } } if (!$header){Write-Warning 'unable to create an auth header with provided parameters';return $null} $url="https://$orgname.api.identitynow.com/v2/accounts/$($accountid)?org=$orgname" $body=$account | ConvertTo-Json -Depth 10 $response=Invoke-WebRequest -UseBasicParsing -Uri $url -Headers $header -Method put -Body $body $account=$response.Content | ConvertFrom-Json return $account } |