Public/update-AllegisIDNAccount.ps1

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
}