Skip to content

Commit 167206d

Browse files
committed
feat: list custom attributes
1 parent 5099c20 commit 167206d

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Settings/Invoke-ExecCustomData.ps1

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,13 @@ function Invoke-ExecCustomData {
334334
}
335335
}
336336
}
337+
'ListAvailableAttributes' {
338+
$TargetObject = $Request.Query.targetObject ?? 'All'
339+
$AvailableAttributes = Get-CippCustomDataAttributes -TargetObject $TargetObject
340+
$Body = @{
341+
Results = @($AvailableAttributes)
342+
}
343+
}
337344
default {
338345
$Body = @{
339346
Results = @(
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
function Get-CippCustomDataAttributes {
2+
<#
3+
.SYNOPSIS
4+
Get the custom data attributes for CIPP
5+
.DESCRIPTION
6+
This function is used to get the custom data attributes for CIPP
7+
#>
8+
[CmdletBinding()]
9+
param(
10+
$TargetObject = 'All'
11+
)
12+
$CustomDataTable = Get-CippTable -tablename 'CustomData'
13+
$CustomDataEntities = Get-CIPPAzDataTableEntity @CustomDataTable
14+
$AvailableAttributes = foreach ($CustomDataEntity in $CustomDataEntities) {
15+
$Type = $CustomDataEntity.PartitionKey
16+
$CustomData = $CustomDataEntity.JSON | ConvertFrom-Json
17+
if ($CustomData) {
18+
if ($Type -eq 'SchemaExtension') {
19+
$Name = $CustomData.id
20+
foreach ($TargetObject in $CustomData.targetTypes) {
21+
[PSCustomObject]@{
22+
name = $Name
23+
targetObject = $TargetObject.ToLower()
24+
properties = $CustomData.properties
25+
}
26+
}
27+
} elseif ($Type -eq 'DirectoryExtension') {
28+
$Name = $CustomData.RowKey
29+
foreach ($TargetObject in $CustomData.targetObjects) {
30+
[PSCustomObject]@{
31+
name = $Name
32+
targetObject = $TargetObject
33+
}
34+
}
35+
}
36+
}
37+
}
38+
39+
if ($TargetObject -eq 'All') {
40+
return $AvailableAttributes
41+
} else {
42+
return $AvailableAttributes | Where-Object { $_.targetObject -eq $TargetObject }
43+
}
44+
}

0 commit comments

Comments
 (0)