Skip to content

Commit c51c9e3

Browse files
committed
Preserve Package property in template operations
Ensures the Package property from existing templates is retained when updating or creating templates in both New-CIPPTemplateRun and Import-CommunityTemplate. This improves consistency and data integrity for template management.
1 parent c3ae8fc commit c51c9e3

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

Modules/CIPPCore/Public/New-CIPPTemplateRun.ps1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ function New-CIPPTemplateRun {
149149
JSON = "$object"
150150
RowKey = $ExistingPolicy.GUID
151151
PartitionKey = 'IntuneTemplate'
152+
Package = $ExistingPolicy.Package
152153
} -Force
153154
} else {
154155
"Policy $($Template.DisplayName) not found in existing templates, creating new template"
@@ -196,6 +197,7 @@ function New-CIPPTemplateRun {
196197
JSON = "$object"
197198
RowKey = $ExistingPolicy.GUID
198199
PartitionKey = 'IntuneTemplate'
200+
Package = $ExistingPolicy.Package
199201
} -Force
200202
} else {
201203
"Policy $($Template.DisplayName) not found in existing templates, creating new template"
@@ -237,6 +239,7 @@ function New-CIPPTemplateRun {
237239
JSON = "$object"
238240
RowKey = $ExistingPolicy.GUID
239241
PartitionKey = 'IntuneTemplate'
242+
Package = $ExistingPolicy.Package
240243
} -Force
241244
} else {
242245
"Policy $($Template.DisplayName) not found in existing templates, creating new template"

Modules/CIPPCore/Public/Tools/Import-CommunityTemplate.ps1

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,6 @@ function Import-CommunityTemplate {
4242
$excludedTenants = $ExistingJSON.excludedTenants
4343
$NewJSON.tenantFilter = $tenantFilter
4444
$NewJSON.excludedTenants = $excludedTenants
45-
46-
# Extract package tag from existing template
47-
$PackageTag = $Existing.Package
48-
if ($PackageTag) {
49-
$Template | Add-Member -MemberType NoteProperty -Name Package -Value $PackageTag -Force
50-
}
5145
}
5246
}
5347

@@ -169,6 +163,11 @@ function Import-CommunityTemplate {
169163
GUID = $ID
170164
RowKey = $ID
171165
}
166+
167+
if ($Existing -and $Existing.Package) {
168+
$entity.Package = $Existing.Package
169+
}
170+
172171
Add-CIPPAzDataTableEntity @Table -Entity $entity -Force
173172

174173
}

0 commit comments

Comments
 (0)