Skip to content

Commit 937aaff

Browse files
Merge pull request KelvinTegelaar#1402 from Ren-Roros-Digital/fix-compare
chore: tweak standards report/alert compare
2 parents c5d51a1 + 2b6a95e commit 937aaff

5 files changed

+60
-51
lines changed

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

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,19 @@ function Invoke-CIPPStandardDefaultPlatformRestrictions {
5858
($CurrentState.windowsRestriction.platformBlocked -eq $Settings.platformWindowsBlocked) -and
5959
($CurrentState.windowsRestriction.personalDeviceEnrollmentBlocked -eq $Settings.personalWindowsBlocked)
6060

61+
$CompareField = [PSCustomObject]@{
62+
platformAndroidForWorkBlocked = $CurrentState.androidForWorkRestriction.platformBlocked
63+
personalAndroidForWorkBlocked = $CurrentState.androidForWorkRestriction.personalDeviceEnrollmentBlocked
64+
platformAndroidBlocked = $CurrentState.androidRestriction.platformBlocked
65+
personalAndroidBlocked = $CurrentState.androidRestriction.personalDeviceEnrollmentBlocked
66+
platformiOSBlocked = $CurrentState.iosRestriction.platformBlocked
67+
personaliOSBlocked = $CurrentState.iosRestriction.personalDeviceEnrollmentBlocked
68+
platformMacOSBlocked = $CurrentState.macOSRestriction.platformBlocked
69+
personalMacOSBlocked = $CurrentState.macOSRestriction.personalDeviceEnrollmentBlocked
70+
platformWindowsBlocked = $CurrentState.windowsRestriction.platformBlocked
71+
personalWindowsBlocked = $CurrentState.windowsRestriction.personalDeviceEnrollmentBlocked
72+
}
73+
6174
If ($Settings.remediate -eq $true) {
6275
if ($StateIsCorrect -eq $true) {
6376
Write-LogMessage -API 'Standards' -Tenant $Tenant -Message 'DefaultPlatformRestrictions is already applied correctly.' -Sev Info
@@ -109,29 +122,17 @@ function Invoke-CIPPStandardDefaultPlatformRestrictions {
109122
}
110123

111124
If ($Settings.alert -eq $true) {
112-
113125
if ($StateIsCorrect -eq $true) {
114126
Write-LogMessage -API 'Standards' -Tenant $Tenant -Message 'DefaultPlatformRestrictions is correctly set.' -Sev Info
115127
} else {
116-
Write-StandardsAlert -message 'DefaultPlatformRestrictions is incorrectly set.' -object $StateIsCorrect -tenant $Tenant -standardName 'DefaultPlatformRestrictions' -standardId $Settings.standardId
128+
Write-StandardsAlert -message 'DefaultPlatformRestrictions is incorrectly set.' -object $CompareField -tenant $Tenant -standardName 'DefaultPlatformRestrictions' -standardId $Settings.standardId
117129
Write-LogMessage -API 'Standards' -Tenant $Tenant -Message 'DefaultPlatformRestrictions is incorrectly set.' -Sev Info
118130
}
119131
}
120132

121133
If ($Settings.report -eq $true) {
122-
$Table = [PSCustomObject]@{
123-
platformAndroidForWorkBlocked = $CurrentState.androidForWorkRestriction.platformBlocked
124-
personalAndroidForWorkBlocked = $CurrentState.androidForWorkRestriction.personalDeviceEnrollmentBlocked
125-
platformAndroidBlocked = $CurrentState.androidRestriction.platformBlocked
126-
personalAndroidBlocked = $CurrentState.androidRestriction.personalDeviceEnrollmentBlocked
127-
platformiOSBlocked = $CurrentState.iosRestriction.platformBlocked
128-
personaliOSBlocked = $CurrentState.iosRestriction.personalDeviceEnrollmentBlocked
129-
platformMacOSBlocked = $CurrentState.macOSRestriction.platformBlocked
130-
personalMacOSBlocked = $CurrentState.macOSRestriction.personalDeviceEnrollmentBlocked
131-
platformWindowsBlocked = $CurrentState.windowsRestriction.platformBlocked
132-
personalWindowsBlocked = $CurrentState.windowsRestriction.personalDeviceEnrollmentBlocked
133-
}
134-
Set-CIPPStandardsCompareField -FieldName 'standards.DefaultPlatformRestrictions' -FieldValue $Table -TenantFilter $Tenant
134+
$FieldValue = $StateIsCorrect ? $true : $CompareField
135+
Set-CIPPStandardsCompareField -FieldName 'standards.DefaultPlatformRestrictions' -FieldValue $FieldValue -TenantFilter $Tenant
135136
Add-CIPPBPAField -FieldName 'DefaultPlatformRestrictions' -FieldValue [bool]$StateIsCorrect -StoreAs bool -Tenant $Tenant
136137
}
137138
}

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

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,18 @@ function Invoke-CIPPStandardMDMScope {
3434
$CurrentInfo = New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/policies/mobileDeviceManagementPolicies/0000000a-0000-0000-c000-000000000000?$expand=includedGroups' -tenantid $Tenant
3535

3636
$StateIsCorrect = ($CurrentInfo.termsOfUseUrl -eq 'https://portal.manage.microsoft.com/TermsofUse.aspx') -and
37-
($CurrentInfo.discoveryUrl -eq 'https://enrollment.manage.microsoft.com/enrollmentserver/discovery.svc') -and
38-
($CurrentInfo.complianceUrl -eq 'https://portal.manage.microsoft.com/?portalAction=Compliance') -and
39-
($CurrentInfo.appliesTo -eq $Settings.appliesTo) -and
40-
($Settings.appliesTo -ne 'selected' -or ($CurrentInfo.includedGroups.displayName -contains $Settings.customGroup))
37+
($CurrentInfo.discoveryUrl -eq 'https://enrollment.manage.microsoft.com/enrollmentserver/discovery.svc') -and
38+
($CurrentInfo.complianceUrl -eq 'https://portal.manage.microsoft.com/?portalAction=Compliance') -and
39+
($CurrentInfo.appliesTo -eq $Settings.appliesTo) -and
40+
($Settings.appliesTo -ne 'selected' -or ($CurrentInfo.includedGroups.displayName -contains $Settings.customGroup))
41+
42+
$CompareField = [PSCustomObject]@{
43+
termsOfUseUrl = $CurrentInfo.termsOfUseUrl
44+
discoveryUrl = $CurrentInfo.discoveryUrl
45+
complianceUrl = $CurrentInfo.complianceUrl
46+
appliesTo = $CurrentInfo.appliesTo
47+
customGroup = $CurrentInfo.includedGroups.displayName
48+
}
4149

4250
If ($Settings.remediate -eq $true) {
4351
if ($StateIsCorrect -eq $true) {
@@ -112,17 +120,17 @@ function Invoke-CIPPStandardMDMScope {
112120
}
113121

114122
if ($Settings.alert -eq $true) {
115-
if ($StateIsCorrect) {
123+
if ($StateIsCorrect -eq $true) {
116124
Write-LogMessage -API 'Standards' -tenant $tenant -message 'MDM Scope is correctly configured' -sev Info
117125
} else {
118-
Write-StandardsAlert -message 'MDM Scope is not correctly configured' -object $CurrentInfo -tenant $tenant -standardName 'MDMScope' -standardId $Settings.standardId
126+
Write-StandardsAlert -message 'MDM Scope is not correctly configured' -object $CompareField -tenant $tenant -standardName 'MDMScope' -standardId $Settings.standardId
119127
Write-LogMessage -API 'Standards' -tenant $tenant -message 'MDM Scope is not correctly configured' -sev Info
120128
}
121129
}
122130

123131
if ($Settings.report -eq $true) {
124-
$state = $StateIsCorrect ? $true : $CurrentInfo
125-
Set-CIPPStandardsCompareField -FieldName 'standards.MDMScope' -FieldValue $state -TenantFilter $Tenant
132+
$FieldValue = $StateIsCorrect ? $true : $CompareField
133+
Set-CIPPStandardsCompareField -FieldName 'standards.MDMScope' -FieldValue $FieldValue -TenantFilter $Tenant
126134
Add-CIPPBPAField -FieldName 'MDMScope' -FieldValue $StateIsCorrect -StoreAs bool -Tenant $tenant
127135
}
128136

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ function Invoke-CIPPStandardPhishSimSpoofIntelligence {
4040

4141
$StateIsCorrect = ($AddDomain.Count -eq 0 -and $RemoveDomain.Count -eq 0)
4242

43+
$CompareField = [PSCustomObject]@{
44+
"Missing Domains" = $AddDomain -join ', '
45+
"Incorrect Domains" = $RemoveDomain.SendingInfrastructure -join ', '
46+
}
47+
4348
If ($Settings.remediate -eq $true) {
4449
If ($StateIsCorrect -eq $true) {
4550
Write-LogMessage -API 'Standards' -Tenant $Tenant -message 'Spoof Intelligence Allow list already correctly configured' -sev Info
@@ -89,15 +94,14 @@ function Invoke-CIPPStandardPhishSimSpoofIntelligence {
8994
If ($StateIsCorrect -eq $true) {
9095
Write-LogMessage -API 'Standards' -Tenant $Tenant -message 'Spoof Intelligence Allow list is correctly configured' -sev Info
9196
} Else {
92-
Write-StandardsAlert -message 'Spoof Intelligence Allow list is not correctly configured' -object $CurrentState -tenant $Tenant -standardName 'PhishSimSpoofIntelligence' -standardId $Settings.standardId
97+
Write-StandardsAlert -message 'Spoof Intelligence Allow list is not correctly configured' -object $CompareField -tenant $Tenant -standardName 'PhishSimSpoofIntelligence' -standardId $Settings.standardId
9398
Write-LogMessage -API 'Standards' -Tenant $Tenant -message 'Spoof Intelligence Allow list is not correctly configured' -sev Info
9499
}
95100
}
96101

97102
If ($Settings.report -eq $true) {
98-
$CurrentState = $StateIsCorrect ? $true : $DomainState.SendingInfrastructure
99-
100-
Set-CIPPStandardsCompareField -FieldName 'standards.PhishSimSpoofIntelligence' -FieldValue $CurrentState -Tenant $Tenant
103+
$FieldValue = $StateIsCorrect ? $true : $CompareField
104+
Set-CIPPStandardsCompareField -FieldName 'standards.PhishSimSpoofIntelligence' -FieldValue $FieldValue -Tenant $Tenant
101105
Add-CIPPBPAField -FieldName 'PhishSimSpoofIntelligence' -FieldValue [bool]$StateIsCorrect -StoreAs bool -Tenant $Tenant
102106
}
103107
}

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

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ function Invoke-CIPPStandardPhishingSimulations {
6666
# Check state for all components
6767
$StateIsCorrect = $PolicyIsCorrect -and $RuleIsCorrect -and $PhishingSimUrlsIsCorrect
6868

69+
$CompareField = [PSCustomObject]@{
70+
Domains = $RuleState.Domains -join ', '
71+
SenderIpRanges = $RuleState.SenderIpRanges -join ', '
72+
PhishingSimUrls = $SimUrlState.value -join ', '
73+
}
74+
6975
If ($Settings.remediate -eq $true) {
7076
If ($StateIsCorrect -eq $true) {
7177
Write-LogMessage -API 'Standards' -Tenant $Tenant -message 'Advanced Phishing Simulations already correctly configured' -sev Info
@@ -157,22 +163,14 @@ function Invoke-CIPPStandardPhishingSimulations {
157163
If ($StateIsCorrect -eq $true) {
158164
Write-LogMessage -API 'Standards' -Tenant $Tenant -message 'Phishing Simulation Configuration is correctly configured' -sev Info
159165
} Else {
160-
Write-StandardsAlert -message 'Phishing Simulation Configuration is not correctly configured' -object $CurrentState -tenant $Tenant -standardName 'PhishingSimulations' -standardId $Settings.standardId
166+
Write-StandardsAlert -message 'Phishing Simulation Configuration is not correctly configured' -object $CompareField -tenant $Tenant -standardName 'PhishingSimulations' -standardId $Settings.standardId
161167
Write-LogMessage -API 'Standards' -Tenant $Tenant -message 'Phishing Simulation Configuration is not correctly configured' -sev Info
162168
}
163169
}
164170

165171
If ($Settings.report -eq $true) {
172+
$FieldValue = $StateIsCorrect ? $true : $CompareField
166173
Add-CIPPBPAField -FieldName 'PhishingSimulations' -FieldValue $StateIsCorrect -StoreAs bool -Tenant $Tenant
167-
If ($StateIsCorrect -eq $true) {
168-
$FieldValue = $true
169-
} Else {
170-
$FieldValue = [PSCustomObject]@{
171-
Domains = $RuleState.Domains
172-
SenderIpRanges = $RuleState.SenderIpRanges
173-
PhishingSimUrls = $SimUrlState.value
174-
}
175-
}
176174
Set-CIPPStandardsCompareField -FieldName 'standards.PhishingSimulations' -FieldValue $FieldValue -Tenant $Tenant
177175
}
178176
}

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

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,15 @@ function Invoke-CIPPStandardSharePointMassDeletionAlert {
4242
$MissingEmailsInSettings = $Settings.NotifyUser.value | Where-Object { $_ -notin $CurrentState.NotifyUser }
4343

4444
$StateIsCorrect = ($EmailsOutsideSettings.Count -eq 0) -and
45-
($MissingEmailsInSettings.Count -eq 0) -and
46-
($CurrentState.Threshold -eq $Settings.Threshold) -and
47-
($CurrentState.TimeWindow -eq $Settings.TimeWindow)
45+
($MissingEmailsInSettings.Count -eq 0) -and
46+
($CurrentState.Threshold -eq $Settings.Threshold) -and
47+
($CurrentState.TimeWindow -eq $Settings.TimeWindow)
48+
49+
$CompareField = [PSCustomObject]@{
50+
'Threshold' = $CurrentState.Threshold
51+
'TimeWindow' = $CurrentState.TimeWindow
52+
'NotifyUser' = $CurrentState.NotifyUser -join ', '
53+
}
4854

4955
If ($Settings.remediate -eq $true) {
5056
If ($StateIsCorrect -eq $true) {
@@ -88,22 +94,14 @@ function Invoke-CIPPStandardSharePointMassDeletionAlert {
8894
If ($StateIsCorrect -eq $true) {
8995
Write-LogMessage -API 'Standards' -Tenant $Tenant -Message 'SharePoint mass deletion of files alert is enabled' -sev Info
9096
} Else {
97+
Write-StandardsAlert -message 'SharePoint mass deletion of files alert is disabled' -object $CompareField -tenant $tenant -standardName 'SharePointMassDeletionAlert' -standardId $Settings.standardId
9198
Write-LogMessage -API 'Standards' -Tenant $Tenant -Message 'SharePoint mass deletion of files alert is disabled' -sev Info
9299
}
93100
}
94101

95102
If ($Settings.report -eq $true) {
96-
If ($StateIsCorrect -eq $true) {
97-
$Table = $true
98-
} Else {
99-
$Table = [PSCustomObject]@{
100-
Threshold = $CurrentState.Threshold
101-
TimeWindow = $CurrentState.TimeWindow
102-
NotifyUser = $CurrentState.NotifyUser
103-
}
104-
}
105-
106-
Set-CIPPStandardsCompareField -FieldName 'standards.SharePointMassDeletionAlert' -FieldValue $Table -TenantFilter $Tenant
103+
$FieldValue = $StateIsCorrect ? $true : $CompareField
104+
Set-CIPPStandardsCompareField -FieldName 'standards.SharePointMassDeletionAlert' -FieldValue $FieldValue -TenantFilter $Tenant
107105
Add-CIPPBPAField -FieldName 'SharePointMassDeletionAlert' -FieldValue [bool]$StateIsCorrect -StoreAs bool -Tenant $Tenant
108106
}
109107
}

0 commit comments

Comments
 (0)