Skip to content

Update contact in Easit GO with data from Active Directory

Scenario

In this scenario we would like to update any contact on demand when a contact triggers an item event.

Code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
    [CmdletBinding()]
    param (
        [Parameter(Mandatory,Position=0)]
        [string]$Base64StringFromStdIn
    )
    begin {
        Import-Module -Name 'Easit.ProcessRunner.GlobalFunctions','Easit.GO.Webservice'
        Write-CustomLog -Message "Starting script"
    }
    process {
        try {
            $easitObject = Convert-EasitGOExportString -InputString $Base64StringFromStdIn
        } catch {
            Write-CustomLog -InputObject $_ -Level ERROR
            return
        }
        if ([string]::IsNullOrEmpty($easitObject.username)) {
            Write-CustomLog -Message "username is empty, send a request with a property named username (and a value for the property) to EPR" -Level ERROR
            return
        }
        $sendToEasitParams = @{
            Url = 'https://go.easit.com'
            Apikey = 'myApikey'
            ImportHandlerIdentifier = 'updateContact'
        }
        try {
            Get-ADUser -Identity $easitObject.username | Send-ToEasitGO @sendToEasitParams
        } catch {
            Write-CustomLog -InputObject $_ -Level ERROR
            return
        }
    }
    end {
        Write-CustomLog -Message "Script complete"
    }