@@ -35,8 +35,12 @@ function Invoke-CIPPStandardPhishSimSpoofIntelligence {
35
35
36
36
[String []]$AddDomain = $Settings.AllowedDomains.value | Where-Object { $_ -notin $DomainState.SendingInfrastructure }
37
37
38
- $RemoveDomain = $DomainState | Where-Object { $_.SendingInfrastructure -notin $Settings.AllowedDomains.value } |
39
- Select-Object - Property Identity, SendingInfrastructure
38
+ if ($Settings.RemoveExtraDomains -eq $true ) {
39
+ $RemoveDomain = $DomainState | Where-Object { $_.SendingInfrastructure -notin $Settings.AllowedDomains.value } |
40
+ Select-Object - Property Identity, SendingInfrastructure
41
+ } else {
42
+ $RemoveDomain = @ ()
43
+ }
40
44
41
45
$StateIsCorrect = ($AddDomain.Count -eq 0 -and $RemoveDomain.Count -eq 0 )
42
46
@@ -51,15 +55,17 @@ function Invoke-CIPPStandardPhishSimSpoofIntelligence {
51
55
} Else {
52
56
$BulkRequests = New-Object System.Collections.Generic.List[Hashtable ]
53
57
54
- # Prepare removal requests
55
- If ($RemoveDomain.Count -gt 0 ) {
56
- Write-Host " Removing $ ( $RemoveDomain.Count ) domains from Spoof Intelligence"
57
- $BulkRequests.Add (@ {
58
- CmdletInput = @ {
59
- CmdletName = ' Remove-TenantAllowBlockListSpoofItems'
60
- Parameters = @ { Identity = ' default' ; Ids = $RemoveDomain.Identity }
61
- }
62
- })
58
+ if ($Settings.RemoveExtraDomains -eq $true ) {
59
+ # Prepare removal requests
60
+ If ($RemoveDomain.Count -gt 0 ) {
61
+ Write-Host " Removing $ ( $RemoveDomain.Count ) domains from Spoof Intelligence"
62
+ $BulkRequests.Add (@ {
63
+ CmdletInput = @ {
64
+ CmdletName = ' Remove-TenantAllowBlockListSpoofItems'
65
+ Parameters = @ { Identity = ' default' ; Ids = $RemoveDomain.Identity }
66
+ }
67
+ })
68
+ }
63
69
}
64
70
65
71
# Prepare addition requests
0 commit comments