Skip to content

Commit dcedfe3

Browse files
logs
1 parent e990bc3 commit dcedfe3

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

Modules/CIPPCore/Public/Standards/Invoke-CIPPStandardIntuneTemplate.ps1

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,19 @@ function Invoke-CIPPStandardIntuneTemplate {
5555
Write-Host "IntuneTemplate: $($Template.TemplateList.value) - Failed to get existing."
5656
}
5757
if ($ExistingPolicy) {
58-
Write-Host "IntuneTemplate: $($Template.TemplateList.value) - Found existing policy."
59-
$RawJSON = Get-CIPPTextReplacement -Text $RawJSON -TenantFilter $Tenant
60-
Write-Host "IntuneTemplate: $($Template.TemplateList.value) - Grabbing JSON existing."
61-
$JSONExistingPolicy = $ExistingPolicy.cippconfiguration | ConvertFrom-Json -ErrorAction SilentlyContinue
62-
Write-Host "IntuneTemplate: $($Template.TemplateList.value) - Got existing JSON. Converting RawJSON to Template"
63-
$JSONTemplate = $RawJSON | ConvertFrom-Json
64-
Write-Host "IntuneTemplate: $($Template.TemplateList.value) - Converted RawJSON to Template."
65-
Write-Host "IntuneTemplate: $($Template.TemplateList.value) - Comparing JSON."
66-
$Compare = Compare-CIPPIntuneObject -ReferenceObject $JSONTemplate -DifferenceObject $JSONExistingPolicy -compareType $Request.body.Type -ErrorAction SilentlyContinue
58+
try {
59+
Write-Host "IntuneTemplate: $($Template.TemplateList.value) - Found existing policy."
60+
$RawJSON = Get-CIPPTextReplacement -Text $RawJSON -TenantFilter $Tenant
61+
Write-Host "IntuneTemplate: $($Template.TemplateList.value) - Grabbing JSON existing."
62+
$JSONExistingPolicy = $ExistingPolicy.cippconfiguration | ConvertFrom-Json
63+
Write-Host "IntuneTemplate: $($Template.TemplateList.value) - Got existing JSON. Converting RawJSON to Template"
64+
$JSONTemplate = $RawJSON | ConvertFrom-Json
65+
Write-Host "IntuneTemplate: $($Template.TemplateList.value) - Converted RawJSON to Template."
66+
Write-Host "IntuneTemplate: $($Template.TemplateList.value) - Comparing JSON."
67+
$Compare = Compare-CIPPIntuneObject -ReferenceObject $JSONTemplate -DifferenceObject $JSONExistingPolicy -compareType $Request.body.Type -ErrorAction SilentlyContinue
68+
} catch {
69+
Write-Host "The compare failed. The error was: $($_.Exception.Message)"
70+
}
6771
Write-Host "IntuneTemplate: $($Template.TemplateList.value) - Compared JSON: $($Compare | ConvertTo-Json -Compress)"
6872
} else {
6973
Write-Host "IntuneTemplate: $($Template.TemplateList.value) - No existing policy found."

0 commit comments

Comments
 (0)