Skip to content

Commit ff856e4

Browse files
add edit template
1 parent 1146c88 commit ff856e4

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Core/Invoke-ExecEditTemplate.ps1

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,19 @@ Function Invoke-ExecEditTemplate {
1515

1616
try {
1717
$Table = Get-CippTable -tablename 'templates'
18-
$Table.Force = $true
1918
$guid = $request.body.guid
2019
$JSON = ConvertTo-Json -Compress -Depth 100 -InputObject ($request.body | Select-Object * -ExcludeProperty GUID)
21-
$Type = $request.Query.Type
20+
$Type = $request.Body.Type
2221

2322
if ($Type -eq 'IntuneTemplate') {
2423
Write-Host 'Intune Template'
25-
Write-Host ''
26-
$RawJSON = $request.body | Select-Object * -ExcludeProperty displayName, description, type, GUID | ConvertTo-Json -Depth 10 -Compress
24+
$OriginalTemplate = Get-CIPPAzDataTableEntity @Table -Filter "PartitionKey eq 'IntuneTemplate' and GUID eq '$GUID'"
25+
$OriginalTemplate = ($OriginalTemplate.JSON | ConvertFrom-Json -Depth 100)
26+
$RawJSON = $OriginalTemplate.RAWJson
2727
Set-CIPPIntuneTemplate -RawJSON $RawJSON -GUID $GUID -DisplayName $Request.body.displayName -Description $Request.body.description -templateType $Request.body.type
2828
} else {
29+
$Table.Force = $true
30+
2931
Add-CIPPAzDataTableEntity @Table -Entity @{
3032
JSON = "$JSON"
3133
RowKey = "$GUID"

Modules/CIPPCore/Public/Set-CIPPIntuneTemplate.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function Set-CIPPIntuneTemplate {
77
$Description,
88
$templateType
99
)
10-
10+
Write-Host "Received $DisplayName, $Description, $RawJSON, $templateType"
1111
if (!$DisplayName) { throw 'You must enter a displayname' }
1212
if ($null -eq ($RawJSON | ConvertFrom-Json)) { throw 'the JSON is invalid' }
1313

0 commit comments

Comments
 (0)