Skip to content

Commit 63ea0e4

Browse files
committed
handles individual and multiple values correctly
1 parent 6ce3831 commit 63ea0e4

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Email-Exchange/Spamfilter/Invoke-AddTenantAllowBlockList.ps1

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,19 @@ Function Invoke-AddTenantAllowBlockList {
1717
$BlockListObject = $Request.Body
1818
if ($Request.Body.tenantId -eq 'AllTenants') { $Tenants = (Get-Tenants).defaultDomainName } else { $Tenants = @($Request.body.tenantId) }
1919
$Results = [System.Collections.Generic.List[string]]::new()
20+
$Entries = @()
21+
if ($BlockListObject.entries -is [array]) {
22+
$Entries = $BlockListObject.entries
23+
} else {
24+
$Entries = @($BlockListObject.entries -split "[,;]" | Where-Object { $_ -ne "" } | ForEach-Object { $_.Trim() })
25+
}
2026
foreach ($Tenant in $Tenants) {
2127
try {
2228
$ExoRequest = @{
2329
tenantid = $Tenant
2430
cmdlet = 'New-TenantAllowBlockListItems'
2531
cmdParams = @{
26-
Entries = [string[]]$BlockListObject.entries
32+
Entries = $Entries
2733
ListType = [string]$BlockListObject.listType
2834
Notes = [string]$BlockListObject.notes
2935
$BlockListObject.listMethod = [bool]$true
@@ -32,6 +38,8 @@ Function Invoke-AddTenantAllowBlockList {
3238

3339
if ($BlockListObject.NoExpiration -eq $true) {
3440
$ExoRequest.cmdParams.NoExpiration = $true
41+
} elseif ($BlockListObject.RemoveAfter -eq $true) {
42+
$ExoRequest.cmdParams.RemoveAfter = 45
3543
}
3644

3745
New-ExoRequest @ExoRequest

0 commit comments

Comments
 (0)