@@ -122,6 +122,8 @@ function Set-CIPPIntunePolicy {
122122 $DisplayName = ($RawJSON | ConvertFrom-Json ).Name
123123 $CheckExististing = New-GraphGETRequest - uri " https://graph.microsoft.com/beta/$PlatformType /$TemplateTypeURL " - tenantid $tenantFilter
124124 if ($DisplayName -in $CheckExististing.name ) {
125+ $PolicyFile = $RawJSON | ConvertFrom-Json | Select-Object * - ExcludeProperty Platform, PolicyType, CreationSource
126+ $RawJSON = ConvertTo-Json - InputObject $PolicyFile - Depth 100 - Compress
125127 $ExistingID = $CheckExististing | Where-Object - Property Name -EQ $DisplayName
126128 $CreateRequest = New-GraphPOSTRequest - uri " https://graph.microsoft.com/beta/$PlatformType /$TemplateTypeURL /$ ( $ExistingID.Id ) " - tenantid $tenantFilter - type PUT - body $RawJSON
127129 $CreateRequest = $CheckExististing | Where-Object - Property Name -EQ $DisplayName
@@ -140,11 +142,12 @@ function Set-CIPPIntunePolicy {
140142 $CheckExististing = New-GraphGETRequest - uri " https://graph.microsoft.com/beta/$PlatformType /$TemplateTypeURL " - tenantid $tenantFilter
141143 if ($DisplayName -in $CheckExististing.displayName ) {
142144 $PostType = ' edited'
145+ $PolicyFile = $RawJSON | ConvertFrom-Json | Select-Object * - ExcludeProperty inventorySyncStatus, newUpdates, deviceReporting, approvalType
146+ $RawJSON = ConvertTo-Json - InputObject $PolicyFile - Depth 100 - Compress
143147 $ExistingID = $CheckExististing | Where-Object - Property displayName -EQ $displayname
144148 Write-Host ' We are editing'
145- $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
146150 $CreateRequest = $CheckExististing | Where-Object - Property displayName -EQ $DisplayName
147-
148151 } else {
149152 $PostType = ' added'
150153 $CreateRequest = New-GraphPOSTRequest - uri " https://graph.microsoft.com/beta/$PlatformType /$TemplateTypeURL " - tenantid $tenantFilter - type POST - body $RawJSON
@@ -159,9 +162,11 @@ function Set-CIPPIntunePolicy {
159162 $CheckExististing = New-GraphGETRequest - uri " https://graph.microsoft.com/beta/$PlatformType /$TemplateTypeURL " - tenantid $tenantFilter
160163 if ($DisplayName -in $CheckExististing.displayName ) {
161164 $PostType = ' edited'
165+ $PolicyFile = $RawJSON | ConvertFrom-Json | Select-Object * - ExcludeProperty deployableContentDisplayName, endOfSupportDate, installLatestWindows10OnWindows11IneligibleDevice
166+ $RawJSON = ConvertTo-Json - InputObject $PolicyFile - Depth 100 - Compress
162167 $ExistingID = $CheckExististing | Where-Object - Property displayName -EQ $displayname
163168 Write-Host ' We are editing'
164- $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
165170 $CreateRequest = $CheckExististing | Where-Object - Property displayName -EQ $DisplayName
166171
167172 } else {
@@ -170,7 +175,46 @@ function Set-CIPPIntunePolicy {
170175 Write-LogMessage - headers $Headers - API $APINAME - tenant $ ($tenantFilter ) - message " Added policy $ ( $DisplayName ) via template" - Sev ' info'
171176 }
172177 }
173-
178+ ' windowsQualityUpdatePolicies' {
179+ $PlatformType = ' deviceManagement'
180+ $TemplateTypeURL = ' windowsQualityUpdatePolicies'
181+ $File = ($RawJSON | ConvertFrom-Json )
182+ $DisplayName = $File.displayName ?? $File.Name
183+ $CheckExististing = New-GraphGETRequest - uri " https://graph.microsoft.com/beta/$PlatformType /$TemplateTypeURL " - tenantid $tenantFilter
184+ if ($DisplayName -in $CheckExististing.displayName ) {
185+ $PostType = ' edited'
186+ $PolicyFile = $RawJSON | ConvertFrom-Json | Select-Object *
187+ $RawJSON = ConvertTo-Json - InputObject $PolicyFile - Depth 100 - Compress
188+ $ExistingID = $CheckExististing | Where-Object - Property displayName -EQ $displayname
189+ Write-Host ' We are editing'
190+ $CreateRequest = New-GraphPOSTRequest - uri " https://graph.microsoft.com/beta/$PlatformType /$TemplateTypeURL /$ ( $ExistingID.Id ) " - tenantid $tenantFilter - type PATCH - body $RawJSON
191+ $CreateRequest = $CheckExististing | Where-Object - Property displayName -EQ $DisplayName
192+ } else {
193+ $PostType = ' added'
194+ $CreateRequest = New-GraphPOSTRequest - uri " https://graph.microsoft.com/beta/$PlatformType /$TemplateTypeURL " - tenantid $tenantFilter - type POST - body $RawJSON
195+ Write-LogMessage - headers $Headers - API $APINAME - tenant $ ($tenantFilter ) - message " Added policy $ ( $DisplayName ) via template" - Sev ' info'
196+ }
197+ }
198+ ' windowsQualityUpdateProfiles' {
199+ $PlatformType = ' deviceManagement'
200+ $TemplateTypeURL = ' windowsQualityUpdateProfiles'
201+ $File = ($RawJSON | ConvertFrom-Json )
202+ $DisplayName = $File.displayName ?? $File.Name
203+ $CheckExististing = New-GraphGETRequest - uri " https://graph.microsoft.com/beta/$PlatformType /$TemplateTypeURL " - tenantid $tenantFilter
204+ if ($DisplayName -in $CheckExististing.displayName ) {
205+ $PostType = ' edited'
206+ $PolicyFile = $RawJSON | ConvertFrom-Json | Select-Object * - ExcludeProperty releaseDateDisplayName, deployableContentDisplayName
207+ $RawJSON = ConvertTo-Json - InputObject $PolicyFile - Depth 100 - Compress
208+ $ExistingID = $CheckExististing | Where-Object - Property displayName -EQ $displayname
209+ Write-Host ' We are editing'
210+ $CreateRequest = New-GraphPOSTRequest - uri " https://graph.microsoft.com/beta/$PlatformType /$TemplateTypeURL /$ ( $ExistingID.Id ) " - tenantid $tenantFilter - type PATCH - body $RawJSON
211+ $CreateRequest = $CheckExististing | Where-Object - Property displayName -EQ $DisplayName
212+ } else {
213+ $PostType = ' added'
214+ $CreateRequest = New-GraphPOSTRequest - uri " https://graph.microsoft.com/beta/$PlatformType /$TemplateTypeURL " - tenantid $tenantFilter - type POST - body $RawJSON
215+ Write-LogMessage - headers $Headers - API $APINAME - tenant $ ($tenantFilter ) - message " Added policy $ ( $DisplayName ) via template" - Sev ' info'
216+ }
217+ }
174218 }
175219 Write-LogMessage - headers $Headers - API $APINAME - tenant $ ($tenantFilter ) - message " $ ( $PostType ) policy $ ( $Displayname ) " - Sev ' Info'
176220 if ($AssignTo ) {
0 commit comments