Skip to content

Commit a602353

Browse files
Merge pull request #1460 from kris6673/issue4166
Feat: Add TERRL status alert
2 parents 2a07d7f + 5fc9a6d commit a602353

File tree

2 files changed

+98
-58
lines changed

2 files changed

+98
-58
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
function Get-CIPPAlertTERRL {
2+
<#
3+
.FUNCTIONALITY
4+
Entrypoint
5+
#>
6+
[CmdletBinding()]
7+
Param (
8+
[Parameter(Mandatory = $false)]
9+
[Alias('input')]
10+
$InputValue,
11+
$TenantFilter
12+
)
13+
14+
try {
15+
# Set threshold with fallback to 80%
16+
$Threshold = if ([string]::IsNullOrWhiteSpace($InputValue)) { 80 } else { [int]$InputValue }
17+
18+
# Get TERRL status
19+
$TerrlStatus = New-ExoRequest -tenantid $TenantFilter -cmdlet 'Get-LimitsEnforcementStatus'
20+
21+
if ($TerrlStatus) {
22+
$UsagePercentage = [math]::Round(($TerrlStatus.ObservedValue / $TerrlStatus.Threshold) * 100, 2)
23+
24+
if ($UsagePercentage -gt $Threshold) {
25+
$AlertData = [PSCustomObject]@{
26+
UsagePercentage = $UsagePercentage
27+
CurrentVolume = $TerrlStatus.ObservedValue
28+
ThresholdLimit = $TerrlStatus.Threshold
29+
EnforcementEnabled = $TerrlStatus.EnforcementEnabled
30+
Verdict = $TerrlStatus.Verdict
31+
Message = 'Tenant is at {0}% of their TERRL limit (using {1} of {2} messages). Tenant Enforcement Status: {3}' -f $UsagePercentage, $TerrlStatus.ObservedValue, $TerrlStatus.Threshold, $TerrlStatus.Verdict
32+
}
33+
Write-AlertTrace -cmdletName $MyInvocation.MyCommand -tenantFilter $TenantFilter -data $AlertData
34+
}
35+
}
36+
} catch {
37+
Write-AlertMessage -tenant $($TenantFilter) -message "Could not get TERRL status for $($TenantFilter): $(Get-NormalizedError -message $_.Exception.message)"
38+
}
39+
}

cspell.json

Lines changed: 59 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -4,66 +4,67 @@
44
"dictionaryDefinitions": [],
55
"dictionaries": [],
66
"words": [
7-
"Intune",
8-
"Entra",
9-
"GDAP",
10-
"CIPP",
11-
"CIPP-API",
12-
"OBEE",
13-
"TNEF",
14-
"winmail",
15-
"AITM",
16-
"Yubikey",
17-
"Sherweb",
18-
"Autotask",
19-
"Connectwise",
20-
"Datto",
21-
"Bluetrait",
22-
"ADMS",
23-
"SSPR",
24-
"PSTN",
25-
"Passwordless",
7+
"ADMS",
8+
"AITM",
9+
"Autotask",
10+
"Bluetrait",
11+
"CIPP",
12+
"CIPP-API",
13+
"Connectwise",
14+
"Datto",
15+
"Entra",
16+
"GDAP",
17+
"Intune",
18+
"OBEE",
19+
"Passwordless",
20+
"PSTN",
21+
"Sherweb",
22+
"SSPR",
23+
"Terrl",
24+
"TNEF",
25+
"winmail",
26+
"Yubikey"
2627
],
2728
"ignoreWords": [
28-
"tenantid",
29-
"APINAME",
30-
"CIPPBPA",
31-
"CIPPCA",
32-
"CIPPSPO",
33-
"CIPPAPI",
34-
"Addins",
35-
"Helptext",
36-
"ADDEDCOMPONENT",
37-
"ADDEDDATE",
38-
"POWERSHELLEQUIVALENT",
39-
"RECOMMENDEDBY",
40-
"UPDATECOMMENTBLOCK",
41-
"DISABLEDFEATURES",
42-
"pscustomobject",
43-
"microsoftonline",
44-
"mdo_safeattachments",
45-
"mdo_highconfidencespamaction",
46-
"mdo_highconfidencephishaction",
47-
"mdo_phisspamacation",
48-
"mdo_spam_notifications_only_for_admins",
49-
"mdo_antiphishingpolicies",
50-
"mdo_phishthresholdlevel",
51-
"mdo_autoforwardingmode",
52-
"mdo_blockmailforward",
53-
"mdo_zapspam",
54-
"mdo_zapphish",
55-
"mdo_zapmalware",
56-
"mdo_safedocuments",
57-
"mdo_commonattachmentsfilter",
58-
"mdo_safeattachmentpolicy",
59-
"mdo_safelinksforemail",
60-
"mdo_safelinksforOfficeApps",
61-
"exo_storageproviderrestricted",
62-
"exo_individualsharing",
63-
"exo_outlookaddins",
64-
"exo_mailboxaudit",
65-
"exo_mailtipsenabled",
66-
"mip_search_auditlog",
29+
"tenantid",
30+
"APINAME",
31+
"CIPPBPA",
32+
"CIPPCA",
33+
"CIPPSPO",
34+
"CIPPAPI",
35+
"Addins",
36+
"Helptext",
37+
"ADDEDCOMPONENT",
38+
"ADDEDDATE",
39+
"POWERSHELLEQUIVALENT",
40+
"RECOMMENDEDBY",
41+
"UPDATECOMMENTBLOCK",
42+
"DISABLEDFEATURES",
43+
"pscustomobject",
44+
"microsoftonline",
45+
"mdo_safeattachments",
46+
"mdo_highconfidencespamaction",
47+
"mdo_highconfidencephishaction",
48+
"mdo_phisspamacation",
49+
"mdo_spam_notifications_only_for_admins",
50+
"mdo_antiphishingpolicies",
51+
"mdo_phishthresholdlevel",
52+
"mdo_autoforwardingmode",
53+
"mdo_blockmailforward",
54+
"mdo_zapspam",
55+
"mdo_zapphish",
56+
"mdo_zapmalware",
57+
"mdo_safedocuments",
58+
"mdo_commonattachmentsfilter",
59+
"mdo_safeattachmentpolicy",
60+
"mdo_safelinksforemail",
61+
"mdo_safelinksforOfficeApps",
62+
"exo_storageproviderrestricted",
63+
"exo_individualsharing",
64+
"exo_outlookaddins",
65+
"exo_mailboxaudit",
66+
"exo_mailtipsenabled",
67+
"mip_search_auditlog"
6768
],
6869
"import": []
6970
}

0 commit comments

Comments
 (0)