Skip to content

Commit fd0495b

Browse files
committed
fix delete standard template action
1 parent 7e89ee6 commit fd0495b

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Tenant/Standards/Invoke-RemoveStandardTemplate.ps1

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using namespace System.Net
22

3-
Function Invoke-RemoveStandardTemplate {
3+
function Invoke-RemoveStandardTemplate {
44
<#
55
.FUNCTIONALITY
66
Entrypoint,AnyTenant
@@ -19,9 +19,20 @@ Function Invoke-RemoveStandardTemplate {
1919
try {
2020
$Table = Get-CippTable -tablename 'templates'
2121
$Filter = "PartitionKey eq 'StandardsTemplateV2' and RowKey eq '$id'"
22-
$ClearRow = Get-CIPPAzDataTableEntity @Table -Filter $Filter -Property PartitionKey, RowKey
22+
$ClearRow = Get-CIPPAzDataTableEntity @Table -Filter $Filter -Property PartitionKey, RowKey, JSON
23+
if (!$ClearRow) {
24+
$Result = "Standards template with id $ID not found"
25+
Write-LogMessage -Headers $Headers -API $APINAME -message $Result -Sev 'Error'
26+
$StatusCode = [HttpStatusCode]::NotFound
27+
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
28+
StatusCode = $StatusCode
29+
Body = @{'Results' = $Result }
30+
})
31+
return
32+
}
33+
$Template = $ClearRow.JSON | ConvertFrom-Json
2334
Remove-AzDataTableEntity -Force @Table -Entity $clearRow
24-
$Result = "Removed Standards Template named $($ClearRow.name) and id $($id)"
35+
$Result = "Removed Standards Template named $($Template.templateName) ($($id))"
2536
Write-LogMessage -Headers $Headers -API $APINAME -message $Result -Sev 'Info'
2637
$StatusCode = [HttpStatusCode]::OK
2738
} catch {

0 commit comments

Comments
 (0)