Skip to content

Commit 0763560

Browse files
Refactor SecureScoreRemediation to use 4 separate autocomplete fields per feedback
Co-authored-by: KelvinTegelaar <[email protected]>
1 parent 9914b85 commit 0763560

File tree

1 file changed

+62
-14
lines changed

1 file changed

+62
-14
lines changed

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

Lines changed: 62 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ function Invoke-CIPPStandardSecureScoreRemediation {
77
.SYNOPSIS
88
(Label) Update Secure Score Control Profiles
99
.DESCRIPTION
10-
(Helptext) Allows bulk updating of Secure Score control profiles across tenants. Configure controls as resolved, ignored, or third-party mitigated to accurately reflect your security posture.
11-
(DocsDescription) Enables automated or template-based updates to Microsoft Secure Score recommendations. This is particularly useful for MSPs managing multiple tenants, allowing you to mark controls as "Third-party mitigation" (e.g., when using Mimecast, IronScales, or other third-party security tools) or set them to other states in bulk. This ensures Secure Scores accurately reflect each tenant's true security posture without repetitive manual updates.
10+
(Helptext) Allows bulk updating of Secure Score control profiles across tenants. Select controls and assign them to different states: Default, Ignored, Third-Party, or Reviewed.
11+
(DocsDescription) Enables automated or template-based updates to Microsoft Secure Score recommendations. This is particularly useful for MSPs managing multiple tenants, allowing you to mark controls as "Third-party" (e.g., when using Mimecast, IronScales, or other third-party security tools) or set them to other states in bulk. This ensures Secure Scores accurately reflect each tenant's true security posture without repetitive manual updates.
1212
.NOTES
1313
CAT
1414
Global Standards
@@ -17,7 +17,10 @@ function Invoke-CIPPStandardSecureScoreRemediation {
1717
EXECUTIVETEXT
1818
Automates the management of Secure Score control profiles by allowing bulk updates across tenants. This ensures accurate representation of security posture when using third-party security tools or when certain controls need to be marked as resolved or ignored, significantly reducing manual administrative overhead for MSPs managing multiple clients.
1919
ADDEDCOMPONENT
20-
{"type":"input","name":"standards.SecureScoreRemediation.Controls","label":"Control Updates (JSON array)","placeholder":"[{\"ControlName\":\"example\",\"State\":\"thirdPartyMitigation\",\"Reason\":\"Using third-party tool\"}]"}
20+
{"type":"autoComplete","multiple":true,"creatable":true,"name":"standards.SecureScoreRemediation.Default","label":"Controls to set to Default"}
21+
{"type":"autoComplete","multiple":true,"creatable":true,"name":"standards.SecureScoreRemediation.Ignored","label":"Controls to set to Ignored"}
22+
{"type":"autoComplete","multiple":true,"creatable":true,"name":"standards.SecureScoreRemediation.ThirdParty","label":"Controls to set to Third-Party"}
23+
{"type":"autoComplete","multiple":true,"creatable":true,"name":"standards.SecureScoreRemediation.Reviewed","label":"Controls to set to Reviewed"}
2124
IMPACT
2225
Low Impact
2326
ADDEDDATE
@@ -32,6 +35,7 @@ function Invoke-CIPPStandardSecureScoreRemediation {
3235
#>
3336

3437
param($Tenant, $Settings)
38+
3539

3640
# Get current secure score controls
3741
try {
@@ -42,10 +46,61 @@ function Invoke-CIPPStandardSecureScoreRemediation {
4246
return
4347
}
4448

49+
# Build list of controls with their desired states
50+
$ControlsToUpdate = [System.Collections.Generic.List[object]]::new()
51+
52+
# Process Default controls
53+
$DefaultControls = $Settings.Default.value ?? $Settings.Default
54+
if ($DefaultControls) {
55+
foreach ($ControlName in $DefaultControls) {
56+
$ControlsToUpdate.Add(@{
57+
ControlName = $ControlName
58+
State = 'default'
59+
Reason = 'Default'
60+
})
61+
}
62+
}
63+
64+
# Process Ignored controls
65+
$IgnoredControls = $Settings.Ignored.value ?? $Settings.Ignored
66+
if ($IgnoredControls) {
67+
foreach ($ControlName in $IgnoredControls) {
68+
$ControlsToUpdate.Add(@{
69+
ControlName = $ControlName
70+
State = 'ignored'
71+
Reason = 'Ignored'
72+
})
73+
}
74+
}
75+
76+
# Process ThirdParty controls
77+
$ThirdPartyControls = $Settings.ThirdParty.value ?? $Settings.ThirdParty
78+
if ($ThirdPartyControls) {
79+
foreach ($ControlName in $ThirdPartyControls) {
80+
$ControlsToUpdate.Add(@{
81+
ControlName = $ControlName
82+
State = 'thirdParty'
83+
Reason = 'ThirdParty'
84+
})
85+
}
86+
}
87+
88+
# Process Reviewed controls
89+
$ReviewedControls = $Settings.Reviewed.value ?? $Settings.Reviewed
90+
if ($ReviewedControls) {
91+
foreach ($ControlName in $ReviewedControls) {
92+
$ControlsToUpdate.Add(@{
93+
ControlName = $ControlName
94+
State = 'reviewed'
95+
Reason = 'Reviewed'
96+
})
97+
}
98+
}
99+
45100
if ($Settings.remediate -eq $true) {
46101
Write-Host 'Processing Secure Score control updates'
47102

48-
foreach ($Control in $Settings.Controls) {
103+
foreach ($Control in $ControlsToUpdate) {
49104
# Skip if this is a Defender control (starts with scid_)
50105
if ($Control.ControlName -match '^scid_') {
51106
Write-LogMessage -API 'Standards' -tenant $tenant -message "Skipping Defender control $($Control.ControlName) - cannot be updated via this API" -sev Info
@@ -55,14 +110,7 @@ function Invoke-CIPPStandardSecureScoreRemediation {
55110
# Build the request body
56111
$Body = @{
57112
state = $Control.State
58-
}
59-
60-
if ($Control.Reason) {
61-
$Body.comment = $Control.Reason
62-
}
63-
64-
if ($Control.VendorInformation) {
65-
$Body.vendorInformation = $Control.VendorInformation
113+
comment = $Control.Reason
66114
}
67115

68116
try {
@@ -86,7 +134,7 @@ function Invoke-CIPPStandardSecureScoreRemediation {
86134
if ($Settings.alert -eq $true) {
87135
$AlertMessages = [System.Collections.Generic.List[string]]::new()
88136

89-
foreach ($Control in $Settings.Controls) {
137+
foreach ($Control in $ControlsToUpdate) {
90138
if ($Control.ControlName -match '^scid_') {
91139
continue
92140
}
@@ -116,7 +164,7 @@ function Invoke-CIPPStandardSecureScoreRemediation {
116164
if ($Settings.report -eq $true) {
117165
$ReportData = [System.Collections.Generic.List[object]]::new()
118166

119-
foreach ($Control in $Settings.Controls) {
167+
foreach ($Control in $ControlsToUpdate) {
120168
if ($Control.ControlName -match '^scid_') {
121169
continue
122170
}

0 commit comments

Comments
 (0)