-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate.ps1
32 lines (31 loc) · 1.37 KB
/
update.ps1
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
############################################
# HelloID-Conn-Prov-Target-GoodHabitz-Update
# PowerShell V2
############################################
try {
if (-not([string]::IsNullOrEmpty($actionContext.Data.EmailAddress))) {
if ($actionContext.References.Account -ne $actionContext.Data.EmailAddress) {
$outputContext.AccountReference = $actionContext.Data.EmailAddress
$outputContext.PreviousData.EmailAddress = $actionContext.References.Account
$outputContext.Success = $true
$outputContext.AuditLogs.Add([PSCustomObject]@{
Message = "AccountReference [$($actionContext.Data.EmailAddress)] successfully updated on field [EmailAddress]"
IsError = $false
})
}
else {
Write-Information 'NoChanges needed for AccountReference'
$outputContext.Success = $true
}
} else {
throw "Mapping EmailAddress is empty this is likely a mapping error"
}
}
catch {
$outputContext.Success = $false
Write-Warning "Error at Line '$($_.InvocationInfo.ScriptLineNumber)': $($_.InvocationInfo.Line). Error: $($_.Exception.Message)"
$outputContext.AuditLogs.Add([PSCustomObject]@{
Message = "Could not create or correlate GoodHabitz account. Error: $($_.Exception.Message)"
IsError = $true
})
}