Skip to content

Commit 53cf47f

Browse files
committed
Implemented #4759 - retains full backwards compatibility.
1 parent 1d1882a commit 53cf47f

File tree

6 files changed

+94
-25
lines changed

6 files changed

+94
-25
lines changed

Config/standards.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2291,6 +2291,13 @@
22912291
],
22922292
"helpText": "This creates a Safe Links policy that automatically scans, tracks, and and enables safe links for Email, Office, and Teams for both external and internal senders",
22932293
"addedComponent": [
2294+
{
2295+
"type": "textField",
2296+
"name": "standards.SafeLinksPolicy.name",
2297+
"label": "Policy Name",
2298+
"required": true,
2299+
"defaultValue": "CIPP Default SafeLinks Policy"
2300+
},
22942301
{
22952302
"type": "switch",
22962303
"label": "AllowClickThrough",
@@ -2338,6 +2345,13 @@
23382345
],
23392346
"helpText": "This creates a Anti-Phishing policy that automatically enables Mailbox Intelligence and spoofing, optional switches for Mail tips.",
23402347
"addedComponent": [
2348+
{
2349+
"type": "textField",
2350+
"name": "standards.AntiPhishPolicy.name",
2351+
"label": "Policy Name",
2352+
"required": true,
2353+
"defaultValue": "CIPP Default Anti-Phishing Policy"
2354+
},
23412355
{
23422356
"type": "number",
23432357
"label": "Phishing email threshold. (Default 1)",
@@ -2548,6 +2562,13 @@
25482562
],
25492563
"helpText": "This creates a Safe Attachment policy",
25502564
"addedComponent": [
2565+
{
2566+
"type": "textField",
2567+
"name": "standards.SafeAttachmentPolicy.name",
2568+
"label": "Policy Name",
2569+
"required": true,
2570+
"defaultValue": "CIPP Default Safe Attachment Policy"
2571+
},
25512572
{
25522573
"type": "select",
25532574
"multiple": false,
@@ -2692,6 +2713,13 @@
26922713
],
26932714
"helpText": "This creates a Malware filter policy that enables the default File filter and Zero-hour auto purge for malware.",
26942715
"addedComponent": [
2716+
{
2717+
"type": "textField",
2718+
"name": "standards.MalwareFilterPolicy.name",
2719+
"label": "Policy Name",
2720+
"required": true,
2721+
"defaultValue": "CIPP Default Malware Policy"
2722+
},
26952723
{
26962724
"type": "select",
26972725
"multiple": false,
@@ -2811,7 +2839,15 @@
28112839
"cat": "Defender Standards",
28122840
"tag": [],
28132841
"helpText": "This standard creates a Spam filter policy similar to the default strict policy.",
2842+
"docsDescription": "This standard creates a Spam filter policy similar to the default strict policy, the following settings are configured to on by default: IncreaseScoreWithNumericIps, IncreaseScoreWithRedirectToOtherPort, MarkAsSpamEmptyMessages, MarkAsSpamJavaScriptInHtml, MarkAsSpamSpfRecordHardFail, MarkAsSpamFromAddressAuthFail, MarkAsSpamNdrBackscatter, MarkAsSpamBulkMail, InlineSafetyTipsEnabled, PhishZapEnabled, SpamZapEnabled",
28142843
"addedComponent": [
2844+
{
2845+
"type": "textField",
2846+
"name": "standards.SpamFilterPolicy.name",
2847+
"label": "Policy Name",
2848+
"required": true,
2849+
"defaultValue": "CIPP Default Spam Filter Policy"
2850+
},
28152851
{
28162852
"type": "number",
28172853
"label": "Bulk email threshold (Default 7)",

Modules/CIPPCore/Public/Standards/Invoke-CIPPStandardAntiPhishPolicy.ps1

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,26 @@ function Invoke-CIPPStandardAntiPhishPolicy {
6464
$MDOLicensed = $ServicePlans -contains "ATP_ENTERPRISE"
6565
Write-Information "MDOLicensed: $MDOLicensed"
6666

67-
$PolicyList = @('CIPP Default Anti-Phishing Policy','Default Anti-Phishing Policy')
68-
$ExistingPolicy = New-ExoRequest -tenantid $Tenant -cmdlet 'Get-AntiPhishPolicy' | Where-Object -Property Name -In $PolicyList
67+
# Use custom name if provided, otherwise use default for backward compatibility
68+
$PolicyName = if ($Settings.name) { $Settings.name } else { 'CIPP Default Anti-Phishing Policy' }
69+
$PolicyList = @($PolicyName, 'CIPP Default Anti-Phishing Policy','Default Anti-Phishing Policy')
70+
$ExistingPolicy = New-ExoRequest -tenantid $Tenant -cmdlet 'Get-AntiPhishPolicy' | Where-Object -Property Name -In $PolicyList | Select-Object -First 1
6971
if ($null -eq $ExistingPolicy.Name) {
70-
$PolicyName = $PolicyList[0]
72+
# No existing policy - use the configured/default name
73+
$PolicyName = if ($Settings.name) { $Settings.name } else { 'CIPP Default Anti-Phishing Policy' }
7174
} else {
75+
# Use existing policy name if found
7276
$PolicyName = $ExistingPolicy.Name
7377
}
74-
$RuleList = @( 'CIPP Default Anti-Phishing Rule','CIPP Default Anti-Phishing Policy')
75-
$ExistingRule = New-ExoRequest -tenantid $Tenant -cmdlet 'Get-AntiPhishRule' | Where-Object -Property Name -In $RuleList
78+
# Derive rule name from policy name, but check for old names for backward compatibility
79+
$DesiredRuleName = "$PolicyName Rule"
80+
$RuleList = @($DesiredRuleName, 'CIPP Default Anti-Phishing Rule','CIPP Default Anti-Phishing Policy')
81+
$ExistingRule = New-ExoRequest -tenantid $Tenant -cmdlet 'Get-AntiPhishRule' | Where-Object -Property Name -In $RuleList | Select-Object -First 1
7682
if ($null -eq $ExistingRule.Name) {
77-
$RuleName = $RuleList[0]
83+
# No existing rule - use the derived name
84+
$RuleName = $DesiredRuleName
7885
} else {
86+
# Use existing rule name if found
7987
$RuleName = $ExistingRule.Name
8088
}
8189

Modules/CIPPCore/Public/Standards/Invoke-CIPPStandardMalwareFilterPolicy.ps1

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,26 @@ function Invoke-CIPPStandardMalwareFilterPolicy {
5050
} #we're done.
5151
##$Rerun -Type Standard -Tenant $Tenant -Settings $Settings 'MalwareFilterPolicy'
5252

53-
$PolicyList = @('CIPP Default Malware Policy', 'Default Malware Policy')
54-
$ExistingPolicy = New-ExoRequest -tenantid $Tenant -cmdlet 'Get-MalwareFilterPolicy' | Where-Object -Property Name -In $PolicyList
53+
# Use custom name if provided, otherwise use default for backward compatibility
54+
$PolicyName = if ($Settings.name) { $Settings.name } else { 'CIPP Default Malware Policy' }
55+
$PolicyList = @($PolicyName, 'CIPP Default Malware Policy', 'Default Malware Policy')
56+
$ExistingPolicy = New-ExoRequest -tenantid $Tenant -cmdlet 'Get-MalwareFilterPolicy' | Where-Object -Property Name -In $PolicyList | Select-Object -First 1
5557
if ($null -eq $ExistingPolicy.Name) {
56-
$PolicyName = $PolicyList[0]
58+
# No existing policy - use the configured/default name
59+
$PolicyName = if ($Settings.name) { $Settings.name } else { 'CIPP Default Malware Policy' }
5760
} else {
61+
# Use existing policy name if found
5862
$PolicyName = $ExistingPolicy.Name
5963
}
60-
$RuleList = @( 'CIPP Default Malware Rule', 'CIPP Default Malware Policy')
61-
$ExistingRule = New-ExoRequest -tenantid $Tenant -cmdlet 'Get-MalwareFilterRule' | Where-Object -Property Name -In $RuleList
64+
# Derive rule name from policy name, but check for old names for backward compatibility
65+
$DesiredRuleName = "$PolicyName Rule"
66+
$RuleList = @($DesiredRuleName, 'CIPP Default Malware Rule', 'CIPP Default Malware Policy')
67+
$ExistingRule = New-ExoRequest -tenantid $Tenant -cmdlet 'Get-MalwareFilterRule' | Where-Object -Property Name -In $RuleList | Select-Object -First 1
6268
if ($null -eq $ExistingRule.Name) {
63-
$RuleName = $RuleList[0]
69+
# No existing rule - use the derived name
70+
$RuleName = $DesiredRuleName
6471
} else {
72+
# Use existing rule name if found
6573
$RuleName = $ExistingRule.Name
6674
}
6775

Modules/CIPPCore/Public/Standards/Invoke-CIPPStandardSafeAttachmentPolicy.ps1

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,26 @@ function Invoke-CIPPStandardSafeAttachmentPolicy {
5050
$MDOLicensed = $ServicePlans -contains 'ATP_ENTERPRISE'
5151

5252
if ($MDOLicensed) {
53-
$PolicyList = @('CIPP Default Safe Attachment Policy', 'Default Safe Attachment Policy')
54-
$ExistingPolicy = New-ExoRequest -tenantid $Tenant -cmdlet 'Get-SafeAttachmentPolicy' | Where-Object -Property Name -In $PolicyList
53+
# Use custom name if provided, otherwise use default for backward compatibility
54+
$PolicyName = if ($Settings.name) { $Settings.name } else { 'CIPP Default Safe Attachment Policy' }
55+
$PolicyList = @($PolicyName, 'CIPP Default Safe Attachment Policy', 'Default Safe Attachment Policy')
56+
$ExistingPolicy = New-ExoRequest -tenantid $Tenant -cmdlet 'Get-SafeAttachmentPolicy' | Where-Object -Property Name -In $PolicyList | Select-Object -First 1
5557
if ($null -eq $ExistingPolicy.Name) {
56-
$PolicyName = $PolicyList[0]
58+
# No existing policy - use the configured/default name
59+
$PolicyName = if ($Settings.name) { $Settings.name } else { 'CIPP Default Safe Attachment Policy' }
5760
} else {
61+
# Use existing policy name if found
5862
$PolicyName = $ExistingPolicy.Name
5963
}
60-
$RuleList = @( 'CIPP Default Safe Attachment Rule', 'CIPP Default Safe Attachment Policy')
61-
$ExistingRule = New-ExoRequest -tenantid $Tenant -cmdlet 'Get-SafeAttachmentRule' | Where-Object -Property Name -In $RuleList
64+
# Derive rule name from policy name, but check for old names for backward compatibility
65+
$DesiredRuleName = "$PolicyName Rule"
66+
$RuleList = @($DesiredRuleName, 'CIPP Default Safe Attachment Rule', 'CIPP Default Safe Attachment Policy')
67+
$ExistingRule = New-ExoRequest -tenantid $Tenant -cmdlet 'Get-SafeAttachmentRule' | Where-Object -Property Name -In $RuleList | Select-Object -First 1
6268
if ($null -eq $ExistingRule.Name) {
63-
$RuleName = $RuleList[0]
69+
# No existing rule - use the derived name
70+
$RuleName = $DesiredRuleName
6471
} else {
72+
# Use existing rule name if found
6573
$RuleName = $ExistingRule.Name
6674
}
6775

Modules/CIPPCore/Public/Standards/Invoke-CIPPStandardSafeLinksPolicy.ps1

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,26 @@ function Invoke-CIPPStandardSafeLinksPolicy {
4949
$MDOLicensed = $ServicePlans -contains 'ATP_ENTERPRISE'
5050

5151
if ($MDOLicensed) {
52-
$PolicyList = @('CIPP Default SafeLinks Policy', 'Default SafeLinks Policy')
53-
$ExistingPolicy = New-ExoRequest -tenantid $Tenant -cmdlet 'Get-SafeLinksPolicy' | Where-Object -Property Name -In $PolicyList
52+
# Use custom name if provided, otherwise use default for backward compatibility
53+
$PolicyName = if ($Settings.name) { $Settings.name } else { 'CIPP Default SafeLinks Policy' }
54+
$PolicyList = @($PolicyName, 'CIPP Default SafeLinks Policy', 'Default SafeLinks Policy')
55+
$ExistingPolicy = New-ExoRequest -tenantid $Tenant -cmdlet 'Get-SafeLinksPolicy' | Where-Object -Property Name -In $PolicyList | Select-Object -First 1
5456
if ($null -eq $ExistingPolicy.Name) {
55-
$PolicyName = $PolicyList[0]
57+
# No existing policy - use the configured/default name
58+
$PolicyName = if ($Settings.name) { $Settings.name } else { 'CIPP Default SafeLinks Policy' }
5659
} else {
60+
# Use existing policy name if found
5761
$PolicyName = $ExistingPolicy.Name
5862
}
59-
$RuleList = @( 'CIPP Default SafeLinks Rule', 'CIPP Default SafeLinks Policy')
60-
$ExistingRule = New-ExoRequest -tenantid $Tenant -cmdlet 'Get-SafeLinksRule' | Where-Object -Property Name -In $RuleList
63+
# Derive rule name from policy name, but check for old names for backward compatibility
64+
$DesiredRuleName = "$PolicyName Rule"
65+
$RuleList = @($DesiredRuleName, 'CIPP Default SafeLinks Rule', 'CIPP Default SafeLinks Policy')
66+
$ExistingRule = New-ExoRequest -tenantid $Tenant -cmdlet 'Get-SafeLinksRule' | Where-Object -Property Name -In $RuleList | Select-Object -First 1
6167
if ($null -eq $ExistingRule.Name) {
62-
$RuleName = $RuleList[0]
68+
# No existing rule - use the derived name
69+
$RuleName = $DesiredRuleName
6370
} else {
71+
# Use existing rule name if found
6472
$RuleName = $ExistingRule.Name
6573
}
6674

Modules/CIPPCore/Public/Standards/Invoke-CIPPStandardSpamFilterPolicy.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ function Invoke-CIPPStandardSpamFilterPolicy {
5858
return $true
5959
} #we're done.
6060

61-
$PolicyName = 'CIPP Default Spam Filter Policy'
61+
# Use custom name if provided, otherwise use default for backward compatibility
62+
$PolicyName = if ($Settings.name) { $Settings.name } else { 'CIPP Default Spam Filter Policy' }
6263

6364
try {
6465
$CurrentState = New-ExoRequest -TenantId $Tenant -cmdlet 'Get-HostedContentFilterPolicy' |

0 commit comments

Comments
 (0)