Skip to content

Commit bd318bc

Browse files
Merge pull request KelvinTegelaar#1173 from Ren-Roros-Digital/IntuneComplianceSettings
feat: added IntuneComplianceSettings standard
2 parents 94b5118 + ec524b1 commit bd318bc

1 file changed

Lines changed: 73 additions & 0 deletions

File tree

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
function Invoke-CIPPStandardIntuneComplianceSettings {
2+
<#
3+
.FUNCTIONALITY
4+
Internal
5+
.COMPONENT
6+
(APIName) IntuneComplianceSettings
7+
.SYNOPSIS
8+
(Label) InTune Compliance settings
9+
.DESCRIPTION
10+
(Helptext) Sets the mark devices with no compliance policy assigned as compliance/non compliant and Compliance status validity period.
11+
(DocsDescription) Sets the mark devices with no compliance policy assigned as compliance/non compliant and Compliance status validity period.
12+
.NOTES
13+
CAT
14+
InTune Standards
15+
TAG
16+
"lowimpact"
17+
ADDEDCOMPONENT
18+
IMPACT
19+
Low Impact
20+
RECOMMENDEDBY
21+
UPDATECOMMENTBLOCK
22+
Run the Tools\Update-StandardsComments.ps1 script to update this comment block
23+
.LINK
24+
https://docs.cipp.app/user-documentation/tenant/standards/edit-standards
25+
#>
26+
27+
param($Tenant, $Settings)
28+
29+
$CurrentState = New-GraphGetRequest -Uri 'https://graph.microsoft.com/beta/deviceManagement/settings' -tenantid $Tenant
30+
31+
if ($null -eq $Settings.secureByDefault) { $Settings.secureByDefault = $true }
32+
if ($null -eq $Settings.deviceComplianceCheckinThresholdDays) { $Settings.deviceComplianceCheckinThresholdDays = $CurrentState.deviceComplianceCheckinThresholdDays }
33+
$StateIsCorrect = ($CurrentState.secureByDefault -eq $Settings.secureByDefault) -and
34+
($CurrentState.deviceComplianceCheckinThresholdDays -eq $Settings.deviceComplianceCheckinThresholdDays)
35+
36+
if ($Settings.remediate -eq $true) {
37+
if ($StateIsCorrect -eq $true) {
38+
Write-LogMessage -API 'Standards' -Tenant $Tenant -Message 'InTune Compliance settings is already applied correctly.' -Sev Info
39+
} else {
40+
try {
41+
$GraphRequest = @{
42+
tenantID = $Tenant
43+
uri = "https://graph.microsoft.com/beta/deviceManagement"
44+
AsApp = $true
45+
Type = 'PATCH'
46+
ContentType = 'application/json; charset=utf-8'
47+
Body = [pscustomobject]@{
48+
settings = [pscustomobject]@{
49+
secureByDefault = $Settings.secureByDefault
50+
deviceComplianceCheckinThresholdDays = $Settings.deviceComplianceCheckinThresholdDays
51+
}
52+
} | ConvertTo-Json -Compress
53+
}
54+
New-GraphPostRequest @GraphRequest
55+
Write-LogMessage -API 'Standards' -Tenant $Tenant -Message 'Successfully updated InTune Compliance settings.' -Sev Info
56+
} catch {
57+
Write-LogMessage -API 'Standards' -Tenant $Tenant -Message "Failed to update InTune Compliance settings." -Sev Error -LogData $_
58+
}
59+
}
60+
}
61+
62+
if ($Settings.alert -eq $true) {
63+
if ($StateIsCorrect -eq $true) {
64+
Write-LogMessage -API 'Standards' -tenant $tenant -message 'InTune Compliance settings is enabled.' -sev Info
65+
} else {
66+
Write-LogMessage -API 'Standards' -tenant $tenant -message 'InTune Compliance settings is not enabled.' -sev Alert
67+
}
68+
}
69+
70+
if ($Settings.report -eq $true) {
71+
Add-CIPPBPAField -FieldName 'IntuneComplianceSettings' -FieldValue $StateIsCorrect -StoreAs bool -Tenant $tenant
72+
}
73+
}

0 commit comments

Comments
 (0)