-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.ps1
More file actions
55 lines (49 loc) · 1.87 KB
/
action.ps1
File metadata and controls
55 lines (49 loc) · 1.87 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# HelloID-Task-SA-Target-HelloID-SendEmail
##########################################
try {
Write-Information "Executing HelloID action: [SendNotification] for: [$($requester.userName)]"
$body = "
<p>
Dear [Recipient],
Product: [$($product.Name)] has been requested by: [$($requester.fullName)] with the following comment:
</p>
<p>
$($request.comment)
</p>
<p>Kind regards,<br>
</p>
<p>HelloID<br>
</p>
"
$splatMailParams = @{
From = 'noreply@helloid.com'
To = $manager.ContactEmail
Subject = 'Product requested'
Body = $body
Confidential = $false
}
Write-Information -Tags 'Email' $splatMailParams
$auditLog = @{
Action = 'SendNotification'
System = 'HelloID'
TargetIdentifier = $product.productGUID
TargetDisplayName = $product.name
Message = "HelloID action: [SendNotification] for: [$($requester.userName)] executed successfully"
IsError = $false
}
Write-Information -Tags 'Audit' -MessageData $auditLog
Write-Information "HelloID action: [SendNotification] for: [$($requester.userName)] executed successfully"
} catch {
$ex = $_
$auditLog = @{
Action = 'SendNotification'
System = 'HelloID'
TargetIdentifier = $product.productGUID
TargetDisplayName = $product.name
Message = "Could not execute HelloID action: [SendNotification] for: [$($requester.userName)], error: $($ex.Exception.Message)"
IsError = $true
}
Write-Information -Tags "Audit" -MessageData $auditLog
Write-Error "Could not execute HelloID action: [SendNotification] for: [$($requester.userName)], error: $($ex.Exception.Message)"
}
#######################################