Powershell-connector

So I've created my first Powershell-connector and added some logging to a file so see what is happening when I browse, synk and provision users to the target system.

I have cmdlets for Get-Users, Get-User, and Update-User.

Get-Users returns an array of objects containing all the attributes that Iäm interested in inserting in UNSAccountB. Get-User only returns one object, but the same number of attributes.

When I try to get all users in Postman, it takes around 20-30 seconds. When I try to get all users with the cmdlet, it takes the same amount of time.

What I'm trying to understand is the logic behind the synchronisation. When I run the synchronisation to get all the users, I see in the log that it runs the cmdlet for Get-Users (takes about the same time as the other) and then it starts to run Get-User on each individual user. This means that a action of getting all users takes about 1,5 hrs.

Can anyone explain if this is how the logic SHOULD work, then I'm interested in trying to understand the resoning. If this is NOT how it's suppose to be, what am I doing wrong and how can I fix it.

/Henrik

Parents Reply Children
  • function Get-Accounts() {
    	if (-not $Global:Accounts) {
        		$Global:Accounts = Invoke-Restmethod https://app1/getusers
    	}
    	$Global:Accounts
    }
    
    function Get-Account($id) {
    	if ($Global:Accounts) {
            $account = New-Object PSCustomObject -Property $global:Accounts[$id]
        else {
            $account = Invoke-Restmethod https://app1/getusers/$id
        }
        $account
    }
    
     <ReadConfiguration>
                    <ListingCommand Command="Get-Accounts"/>
                    <CommandSequence>
                        <Item Command="Get-Account" Order="1"/>
                    </CommandSequence>
    </ReadConfiguration>