Skip to content

Commit ff33992

Browse files
standards
1 parent 1469ea8 commit ff33992

18 files changed

+72
-49
lines changed

Modules/CIPPCore/Public/Set-StandardCompareField.ps1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ function Set-CIPPStandardsCompareField {
66
)
77
$Table = Get-CippTable -tablename 'CippStandardsReports'
88
$TenantName = Get-Tenants | Where-Object -Property defaultDomainName -EQ $Tenant
9+
#if the fieldname does not contain standards. prepend it.
10+
if ($FieldName -notlike 'standards.*') {
11+
$FieldName = "standards.$FieldName"
12+
}
913
if ($FieldValue -is [System.Boolean]) {
1014
$fieldValue = [bool]$FieldValue
1115
} elseif ($FieldValue -is [string]) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function Invoke-CIPPStandardEXODisableAutoForwarding {
6666

6767
if ($Settings.report -eq $true) {
6868
$state = $StateIsCorrect ? $true : $CurrentInfo.AutoForwardingMode
69-
Set-CIPPStandardsCompareField -FieldName 'AutoForwardingDisabled' -FieldValue $state -TenantFilter $Tenant
69+
Set-CIPPStandardsCompareField -FieldName 'standards.AutoForwardingDisabled' -FieldValue $state -TenantFilter $Tenant
7070
Add-CIPPBPAField -FieldName 'AutoForwardingDisabled' -FieldValue $StateIsCorrect -StoreAs bool -Tenant $tenant
7171
}
7272

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function Invoke-CIPPStandardExternalMFATrusted {
6666
}
6767
if ($Settings.report -eq $true) {
6868
$state = $ExternalMFATrusted.inboundTrust.isMfaAccepted ? $true : $ExternalMFATrusted.inboundTrust
69-
Set-CIPPStandardsCompareField -FieldName 'ExternalMFATrusted' -FieldValue $ExternalMFATrusted.inboundTrust.isMfaAccepted -TenantFilter $Tenant
69+
Set-CIPPStandardsCompareField -FieldName 'standards.ExternalMFATrusted' -FieldValue $ExternalMFATrusted.inboundTrust.isMfaAccepted -TenantFilter $Tenant
7070
Add-CIPPBPAField -FieldName 'ExternalMFATrusted' -FieldValue $ExternalMFATrusted.inboundTrust.isMfaAccepted -StoreAs bool -Tenant $Tenant
7171
}
7272

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ function Invoke-CIPPStandardFocusedInbox {
7272
}
7373

7474
if ($Settings.report -eq $true) {
75-
Set-CIPPStandardsCompareField -FieldName 'FocusedInboxCorrectState' -FieldValue $StateIsCorrect -TenantFilter $Tenant
75+
Set-CIPPStandardsCompareField -FieldName 'standards.FocusedInboxCorrectState' -FieldValue $StateIsCorrect -TenantFilter $Tenant
7676
Add-CIPPBPAField -FieldName 'FocusedInboxCorrectState' -FieldValue $StateIsCorrect -StoreAs bool -Tenant $Tenant
7777
}
7878
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function Invoke-CIPPStandardGlobalQuarantineNotifications {
4545

4646
if ($Settings.report -eq $true) {
4747
$ReportState = $CurrentState.EndUserSpamNotificationFrequency -eq $WantedState ? $true : $CurrentState.EndUserSpamNotificationFrequency
48-
Set-CIPPStandardsCompareField -FieldName 'GlobalQuarantineNotificationsSet' -FieldValue $ReportState -Tenant $Tenant
48+
Set-CIPPStandardsCompareField -FieldName 'standards.GlobalQuarantineNotificationsSet' -FieldValue $ReportState -Tenant $Tenant
4949
Add-CIPPBPAField -FieldName 'GlobalQuarantineNotificationsSet' -FieldValue [string]$CurrentState.EndUserSpamNotificationFrequency -StoreAs string -Tenant $Tenant
5050
}
5151
# Get notification interval using null-coalescing operator

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ function Invoke-CIPPStandardGuestInvite {
7474
}
7575

7676
if ($Settings.report -eq $true) {
77-
Set-CIPPStandardsCompareField -FieldName 'GuestInvite' -FieldValue $StateIsCorrect -TenantFilter $Tenant
77+
Set-CIPPStandardsCompareField -FieldName 'standards.GuestInvite' -FieldValue $StateIsCorrect -TenantFilter $Tenant
7878
Add-CIPPBPAField -FieldName 'GuestInvite' -FieldValue $StateIsCorrect -StoreAs bool -Tenant $tenant
7979
}
8080
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,14 @@ function Invoke-CIPPStandardIntuneComplianceSettings {
6969
if ($StateIsCorrect -eq $true) {
7070
Write-LogMessage -API 'Standards' -Tenant $Tenant -Message 'Intune Compliance settings is enabled.' -Sev Info
7171
} else {
72-
Write-StandardsAlert -message "Intune Compliance settings is not enabled" -object $CurrentState -tenant $Tenant -standardName 'IntuneComplianceSettings' -standardId $Settings.standardId
72+
Write-StandardsAlert -message 'Intune Compliance settings is not enabled' -object $CurrentState -tenant $Tenant -standardName 'IntuneComplianceSettings' -standardId $Settings.standardId
7373
Write-LogMessage -API 'Standards' -Tenant $Tenant -Message 'Intune Compliance settings is not enabled.' -Sev Info
7474
}
7575
}
7676

7777
if ($Settings.report -eq $true) {
78+
$state = $StateIsCorrect ? $true : $CurrentState
79+
Set-CIPPStandardsCompareField -FieldName 'standards.IntuneComplianceSettings' -FieldValue $state -Tenant $Tenant
7880
Add-CIPPBPAField -FieldName 'IntuneComplianceSettings' -FieldValue $StateIsCorrect -StoreAs bool -Tenant $Tenant
7981
}
8082
}

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,12 @@ function Invoke-CIPPStandardIntuneTemplate {
116116
}
117117

118118
if ($Settings.report) {
119-
#think about how to store this. Consideration: standards are stored seperately from BPA so they can be stored in the same format as the input.
120-
Add-CIPPBPAField -FieldName "policy-$displayname" -FieldValue $Compare -StoreAs bool -Tenant $tenant
119+
foreach ($Template in $CompareList) {
120+
$id = $Template.body.RowKey
121+
$Compare = $Template.compare
122+
$state = $Compare ? $Compare : $true
123+
Set-CIPPStandardsCompareField -FieldName "standards.IntuneTemplate.$id" -FieldValue $state -TenantFilter $Tenant
124+
}
125+
Add-CIPPBPAField -FieldName "policy-$id" -FieldValue $Compare -StoreAs bool -Tenant $tenant
121126
}
122127
}

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

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function Invoke-CIPPStandardMDMScope {
3333

3434
$CurrentInfo = New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/policies/mobileDeviceManagementPolicies/0000000a-0000-0000-c000-000000000000?$expand=includedGroups' -tenantid $Tenant
3535

36-
$StateIsCorrect = ($CurrentInfo.termsOfUseUrl -eq 'https://portal.manage.microsoft.com/TermsofUse.aspx') -and
36+
$StateIsCorrect = ($CurrentInfo.termsOfUseUrl -eq 'https://portal.manage.microsoft.com/TermsofUse.aspx') -and
3737
($CurrentInfo.discoveryUrl -eq 'https://enrollment.manage.microsoft.com/enrollmentserver/discovery.svc') -and
3838
($CurrentInfo.complianceUrl -eq 'https://portal.manage.microsoft.com/?portalAction=Compliance') -and
3939
($CurrentInfo.appliesTo -eq $Settings.appliesTo) -and
@@ -44,15 +44,15 @@ function Invoke-CIPPStandardMDMScope {
4444
Write-LogMessage -API 'Standards' -tenant $tenant -message 'MDM Scope already correctly configured' -sev Info
4545
} else {
4646
$GraphParam = @{
47-
tenantid = $tenant
48-
Uri = 'https://graph.microsoft.com/beta/policies/mobileDeviceManagementPolicies/0000000a-0000-0000-c000-000000000000'
49-
ContentType = 'application/json; charset=utf-8'
50-
asApp = $false
51-
type = 'PATCH'
47+
tenantid = $tenant
48+
Uri = 'https://graph.microsoft.com/beta/policies/mobileDeviceManagementPolicies/0000000a-0000-0000-c000-000000000000'
49+
ContentType = 'application/json; charset=utf-8'
50+
asApp = $false
51+
type = 'PATCH'
5252
AddedHeaders = @{'Accept-Language' = 0 }
53-
Body = @{
53+
Body = @{
5454
'termsOfUseUrl' = 'https://portal.manage.microsoft.com/TermsofUse.aspx'
55-
'discoveryUrl' = 'https://enrollment.manage.microsoft.com/enrollmentserver/discovery.svc'
55+
'discoveryUrl' = 'https://enrollment.manage.microsoft.com/enrollmentserver/discovery.svc'
5656
'complianceUrl' = 'https://portal.manage.microsoft.com/?portalAction=Compliance'
5757
} | ConvertTo-Json
5858
}
@@ -62,19 +62,19 @@ function Invoke-CIPPStandardMDMScope {
6262
Write-LogMessage -API 'Standards' -tenant $tenant -message 'Successfully configured MDM Scope' -sev Info
6363
} catch {
6464
$ErrorMessage = Get-NormalizedError -Message $_.Exception.Message
65-
Write-LogMessage -API 'Standards' -tenant $tenant -message "Failed to configure MDM Scope." -sev Error -LogData $ErrorMessage
65+
Write-LogMessage -API 'Standards' -tenant $tenant -message 'Failed to configure MDM Scope.' -sev Error -LogData $ErrorMessage
6666
}
6767

6868
# Workaround for MDM Scope Assignment error: "Could not set MDM Scope for [TENANT]: Simultaneous patch requests on both the appliesTo and URL properties are currently not supported."
6969
if ($Settings.appliesTo -ne 'selected') {
7070
$GraphParam = @{
71-
tenantid = $tenant
72-
Uri = 'https://graph.microsoft.com/beta/policies/mobileDeviceManagementPolicies/0000000a-0000-0000-c000-000000000000'
73-
ContentType = 'application/json; charset=utf-8'
74-
asApp = $false
75-
type = 'PATCH'
71+
tenantid = $tenant
72+
Uri = 'https://graph.microsoft.com/beta/policies/mobileDeviceManagementPolicies/0000000a-0000-0000-c000-000000000000'
73+
ContentType = 'application/json; charset=utf-8'
74+
asApp = $false
75+
type = 'PATCH'
7676
AddedHeaders = @{'Accept-Language' = 0 }
77-
Body = @{
77+
Body = @{
7878
'appliesTo' = $Settings.appliesTo
7979
} | ConvertTo-Json
8080
}
@@ -89,13 +89,13 @@ function Invoke-CIPPStandardMDMScope {
8989
} else {
9090
$GroupID = (New-GraphGetRequest -Uri "https://graph.microsoft.com/beta/groups?`$top=999&`$select=id,displayName&`$filter=displayName eq '$($Settings.customGroup)'" -tenantid $tenant -asApp $true).id
9191
$GraphParam = @{
92-
tenantid = $tenant
93-
Uri = 'https://graph.microsoft.com/beta/policies/mobileDeviceManagementPolicies/0000000a-0000-0000-c000-000000000000/includedGroups/$ref'
94-
ContentType = 'application/json; charset=utf-8'
95-
asApp = $false
96-
type = 'POST'
92+
tenantid = $tenant
93+
Uri = 'https://graph.microsoft.com/beta/policies/mobileDeviceManagementPolicies/0000000a-0000-0000-c000-000000000000/includedGroups/$ref'
94+
ContentType = 'application/json; charset=utf-8'
95+
asApp = $false
96+
type = 'POST'
9797
AddedHeaders = @{'Accept-Language' = 0 }
98-
Body = @{
98+
Body = @{
9999
'@odata.id' = "https://graph.microsoft.com/odata/groups('$GroupID')"
100100
} | ConvertTo-Json
101101
}
@@ -115,12 +115,14 @@ function Invoke-CIPPStandardMDMScope {
115115
if ($StateIsCorrect) {
116116
Write-LogMessage -API 'Standards' -tenant $tenant -message 'MDM Scope is correctly configured' -sev Info
117117
} else {
118-
Write-StandardsAlert -message "MDM Scope is not correctly configured" -object $CurrentInfo -tenant $tenant -standardName 'MDMScope' -standardId $Settings.standardId
118+
Write-StandardsAlert -message 'MDM Scope is not correctly configured' -object $CurrentInfo -tenant $tenant -standardName 'MDMScope' -standardId $Settings.standardId
119119
Write-LogMessage -API 'Standards' -tenant $tenant -message 'MDM Scope is not correctly configured' -sev Info
120120
}
121121
}
122122

123123
if ($Settings.report -eq $true) {
124+
$state = $StateIsCorrect ? $true : $CurrentInfo
125+
Set-CIPPStandardsCompareField -FieldName 'standards.MDMScope' -FieldValue $state -TenantFilter $Tenant
124126
Add-CIPPBPAField -FieldName 'MDMScope' -FieldValue $StateIsCorrect -StoreAs bool -Tenant $tenant
125127
}
126128

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ function Invoke-CIPPStandardMailContacts {
4040
$TechAndSecurityContacts = @($Contacts.SecurityContact, $Contacts.TechContact)
4141

4242
If ($Settings.remediate -eq $true) {
43-
44-
if ($CurrentInfo.marketingNotificationEmails -eq $Contacts.MarketingContact -and `
45-
($CurrentInfo.securityComplianceNotificationMails -in $TechAndSecurityContacts -or
46-
$CurrentInfo.technicalNotificationMails -in $TechAndSecurityContacts) -and `
47-
$CurrentInfo.privacyProfile.contactEmail -eq $Contacts.GeneralContact) {
43+
$state = $CurrentInfo.marketingNotificationEmails -eq $Contacts.MarketingContact -and `
44+
($CurrentInfo.securityComplianceNotificationMails -in $TechAndSecurityContacts -or
45+
$CurrentInfo.technicalNotificationMails -in $TechAndSecurityContacts) -and `
46+
$CurrentInfo.privacyProfile.contactEmail -eq $Contacts.GeneralContact
47+
if ($state) {
4848
Write-LogMessage -API 'Standards' -tenant $tenant -message 'Contact emails are already set.' -sev Info
4949
} else {
5050
try {
@@ -94,6 +94,8 @@ function Invoke-CIPPStandardMailContacts {
9494

9595
}
9696
if ($Settings.report -eq $true) {
97+
$ReportState = $state ? $true : $CurrentInfo
98+
Set-CIPPStandardsCompareField -FieldName 'standards.MailContacts' -FieldValue $ReportState -Tenant $tenant
9799
Add-CIPPBPAField -FieldName 'MailContacts' -FieldValue $CurrentInfo -StoreAs json -Tenant $tenant
98100
}
99101
}

0 commit comments

Comments
 (0)