@@ -175,7 +175,46 @@ function Set-CIPPIntunePolicy {
175175 Write-LogMessage - headers $Headers - API $APINAME - tenant $ ($tenantFilter ) - message " Added policy $ ( $DisplayName ) via template" - Sev ' info'
176176 }
177177 }
178-
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+ }
179218 }
180219 Write-LogMessage - headers $Headers - API $APINAME - tenant $ ($tenantFilter ) - message " $ ( $PostType ) policy $ ( $Displayname ) " - Sev ' Info'
181220 if ($AssignTo ) {
0 commit comments