@@ -33,7 +33,7 @@ function Invoke-CIPPStandardMDMScope {
33
33
34
34
$CurrentInfo = New-GraphGetRequest - uri ' https://graph.microsoft.com/beta/policies/mobileDeviceManagementPolicies/0000000a-0000-0000-c000-000000000000?$expand=includedGroups' - tenantid $Tenant
35
35
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
37
37
($CurrentInfo.discoveryUrl -eq ' https://enrollment.manage.microsoft.com/enrollmentserver/discovery.svc' ) -and
38
38
($CurrentInfo.complianceUrl -eq ' https://portal.manage.microsoft.com/?portalAction=Compliance' ) -and
39
39
($CurrentInfo.appliesTo -eq $Settings.appliesTo ) -and
@@ -44,15 +44,15 @@ function Invoke-CIPPStandardMDMScope {
44
44
Write-LogMessage - API ' Standards' - tenant $tenant - message ' MDM Scope already correctly configured' - sev Info
45
45
} else {
46
46
$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'
52
52
AddedHeaders = @ {' Accept-Language' = 0 }
53
- Body = @ {
53
+ Body = @ {
54
54
' 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'
56
56
' complianceUrl' = ' https://portal.manage.microsoft.com/?portalAction=Compliance'
57
57
} | ConvertTo-Json
58
58
}
@@ -62,19 +62,19 @@ function Invoke-CIPPStandardMDMScope {
62
62
Write-LogMessage - API ' Standards' - tenant $tenant - message ' Successfully configured MDM Scope' - sev Info
63
63
} catch {
64
64
$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
66
66
}
67
67
68
68
# 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."
69
69
if ($Settings.appliesTo -ne ' selected' ) {
70
70
$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'
76
76
AddedHeaders = @ {' Accept-Language' = 0 }
77
- Body = @ {
77
+ Body = @ {
78
78
' appliesTo' = $Settings.appliesTo
79
79
} | ConvertTo-Json
80
80
}
@@ -89,13 +89,13 @@ function Invoke-CIPPStandardMDMScope {
89
89
} else {
90
90
$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
91
91
$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'
97
97
AddedHeaders = @ {' Accept-Language' = 0 }
98
- Body = @ {
98
+ Body = @ {
99
99
' @odata.id' = " https://graph.microsoft.com/odata/groups('$GroupID ')"
100
100
} | ConvertTo-Json
101
101
}
@@ -115,12 +115,14 @@ function Invoke-CIPPStandardMDMScope {
115
115
if ($StateIsCorrect ) {
116
116
Write-LogMessage - API ' Standards' - tenant $tenant - message ' MDM Scope is correctly configured' - sev Info
117
117
} 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
119
119
Write-LogMessage - API ' Standards' - tenant $tenant - message ' MDM Scope is not correctly configured' - sev Info
120
120
}
121
121
}
122
122
123
123
if ($Settings.report -eq $true ) {
124
+ $state = $StateIsCorrect ? $true : $CurrentInfo
125
+ Set-CIPPStandardsCompareField - FieldName ' standards.MDMScope' - FieldValue $state - TenantFilter $Tenant
124
126
Add-CIPPBPAField - FieldName ' MDMScope' - FieldValue $StateIsCorrect - StoreAs bool - Tenant $tenant
125
127
}
126
128
0 commit comments