Skip to content

Commit 40a5b84

Browse files
committed
add import logic for AppPermissions
1 parent 8f5ae25 commit 40a5b84

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,22 @@ function Import-CommunityTemplate {
4343
$NewJSON.excludedTenants = $excludedTenants
4444
}
4545
}
46+
47+
if ($Template.PartitionKey -eq 'AppApprovalTemplate') {
48+
# Extract the Permission Set name,id,permissions from the JSON and add to the AppPermissions table
49+
$AppPermissionsTable = Get-CIPPTable -TableName 'AppPermissions'
50+
$Permissions = $NewJSON.Permissions
51+
$Entity = @{
52+
'PartitionKey' = 'Templates'
53+
'RowKey' = $NewJSON.PermissionSetId
54+
'TemplateName' = $NewJSON.PermissionSetName
55+
'Permissions' = [string]($Permissions | ConvertTo-Json -Depth 10 -Compress)
56+
'UpdatedBy' = $NewJSON.UpdatedBy ?? $NewJSON.CreatedBy ?? 'System'
57+
}
58+
$null = Add-CIPPAzDataTableEntity @AppPermissionsTable -Entity $Entity -Force
59+
Write-Information 'Added App Permissions to AppPermissions table'
60+
}
61+
4662
# Re-compress JSON and save to table
4763
$NewJSON = [string]($NewJSON | ConvertTo-Json -Depth 100 -Compress)
4864
$Template.JSON = $NewJSON

0 commit comments

Comments
 (0)