Skip to content

Commit

Permalink
Update Compliance Quickfix
Browse files Browse the repository at this point in the history
  • Loading branch information
OfficialEsco committed Aug 12, 2024
1 parent e02c23e commit 0124f95
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Modules/CIPPCore/Public/Set-CIPPIntunePolicy.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function Set-CIPPIntunePolicy {
$CheckExististing = New-GraphGETRequest -uri "https://graph.microsoft.com/beta/deviceAppManagement/$TemplateTypeURL" -tenantid $tenantFilter
if ($displayname -in $CheckExististing.displayName) {
$PostType = 'edited'
$ExistingID = $CheckExististing | Where-Object -Property displayName -EQ $PolicyName
$ExistingID = $CheckExististing | Where-Object -Property displayName -EQ $DisplayName
$CreateRequest = New-GraphPOSTRequest -uri "https://graph.microsoft.com/beta/deviceAppManagement/$TemplateTypeURL/$($ExistingID.Id)" -tenantid $tenantFilter -type PATCH -body $RawJSON
} else {
$PostType = 'added'
Expand All @@ -32,18 +32,18 @@ function Set-CIPPIntunePolicy {
$TemplateTypeURL = 'deviceCompliancePolicies'
$CheckExististing = New-GraphGETRequest -uri "https://graph.microsoft.com/beta/deviceManagement/$TemplateTypeURL" -tenantid $tenantFilter
$JSON = $RawJSON | ConvertFrom-Json | Select-Object * -ExcludeProperty id, createdDateTime, lastModifiedDateTime, version, 'scheduledActionsForRule@odata.context', '@odata.context'
$JSON.scheduledActionsForRule = @($JSON.scheduledActionsForRule | Select-Object * -ExcludeProperty 'scheduledActionConfigurations@odata.context')
$RawJSON = ConvertTo-Json -InputObject $JSON -Depth 20 -Compress
Write-Host $RawJSON
if ($displayname -in $CheckExististing.displayName) {
$PostType = 'edited'
$ExistingID = $CheckExististing | Where-Object -Property displayName -EQ $PolicyName
$ExistingID = $CheckExististing | Where-Object -Property displayName -EQ $DisplayName
$CreateRequest = New-GraphPOSTRequest -uri "https://graph.microsoft.com/beta/deviceManagement/$TemplateTypeURL/$($ExistingID.Id)" -tenantid $tenantFilter -type PATCH -body $RawJSON
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($tenantFilter) -message "Updated policy $($PolicyName) to template defaults" -Sev 'info'
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($tenantFilter) -message "Updated policy $($DisplayName) to template defaults" -Sev 'info'
} else {
$PostType = 'added'
$JSON.scheduledActionsForRule = @($JSON.scheduledActionsForRule | Select-Object * -ExcludeProperty 'scheduledActionConfigurations@odata.context')
$CreateRequest = New-GraphPOSTRequest -uri "https://graph.microsoft.com/beta/deviceManagement/$TemplateTypeURL" -tenantid $tenantFilter -type POST -body $RawJSON
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($tenantFilter) -message "Added policy $($PolicyName) via template" -Sev 'info'
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($tenantFilter) -message "Added policy $($DisplayName) via template" -Sev 'info'
}
}
'Admin' {
Expand Down

0 comments on commit 0124f95

Please sign in to comment.