@@ -142,11 +142,12 @@ function Set-CIPPIntunePolicy {
142142 $CheckExististing = New-GraphGETRequest - uri " https://graph.microsoft.com/beta/$PlatformType /$TemplateTypeURL " - tenantid $tenantFilter
143143 if ($DisplayName -in $CheckExististing.displayName ) {
144144 $PostType = ' edited'
145+ $PolicyFile = $RawJSON | ConvertFrom-Json | Select-Object * - ExcludeProperty inventorySyncStatus, newUpdates, deviceReporting, approvalType
146+ $RawJSON = ConvertTo-Json - InputObject $PolicyFile - Depth 100 - Compress
145147 $ExistingID = $CheckExististing | Where-Object - Property displayName -EQ $displayname
146148 Write-Host ' We are editing'
147- $CreateRequest = New-GraphPOSTRequest - uri " https://graph.microsoft.com/beta/$PlatformType /$TemplateTypeURL /$ ( $ExistingID.Id ) " - tenantid $tenantFilter - type PUT - body $RawJSON
149+ $CreateRequest = New-GraphPOSTRequest - uri " https://graph.microsoft.com/beta/$PlatformType /$TemplateTypeURL /$ ( $ExistingID.Id ) " - tenantid $tenantFilter - type PATCH - body $RawJSON
148150 $CreateRequest = $CheckExististing | Where-Object - Property displayName -EQ $DisplayName
149-
150151 } else {
151152 $PostType = ' added'
152153 $CreateRequest = New-GraphPOSTRequest - uri " https://graph.microsoft.com/beta/$PlatformType /$TemplateTypeURL " - tenantid $tenantFilter - type POST - body $RawJSON
@@ -161,9 +162,11 @@ function Set-CIPPIntunePolicy {
161162 $CheckExististing = New-GraphGETRequest - uri " https://graph.microsoft.com/beta/$PlatformType /$TemplateTypeURL " - tenantid $tenantFilter
162163 if ($DisplayName -in $CheckExististing.displayName ) {
163164 $PostType = ' edited'
165+ $PolicyFile = $RawJSON | ConvertFrom-Json | Select-Object * - ExcludeProperty deployableContentDisplayName, endOfSupportDate, installLatestWindows10OnWindows11IneligibleDevice
166+ $RawJSON = ConvertTo-Json - InputObject $PolicyFile - Depth 100 - Compress
164167 $ExistingID = $CheckExististing | Where-Object - Property displayName -EQ $displayname
165168 Write-Host ' We are editing'
166- $CreateRequest = New-GraphPOSTRequest - uri " https://graph.microsoft.com/beta/$PlatformType /$TemplateTypeURL /$ ( $ExistingID.Id ) " - tenantid $tenantFilter - type PUT - body $RawJSON
169+ $CreateRequest = New-GraphPOSTRequest - uri " https://graph.microsoft.com/beta/$PlatformType /$TemplateTypeURL /$ ( $ExistingID.Id ) " - tenantid $tenantFilter - type PATCH - body $RawJSON
167170 $CreateRequest = $CheckExististing | Where-Object - Property displayName -EQ $DisplayName
168171
169172 } else {
0 commit comments