Skip to content

Commit cba5f92

Browse files
add tag support
1 parent 9a61b67 commit cba5f92

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Endpoint/MEM/Invoke-ListIntuneTemplates.ps1

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,35 @@ function Invoke-ListIntuneTemplates {
5353

5454
} | Sort-Object -Property displayName
5555
} else {
56-
$Templates = $RawTemplates.JSON | ForEach-Object { try { ConvertFrom-Json -InputObject $_ -Depth 100 -ErrorAction SilentlyContinue } catch {} }
56+
if ($Request.query.mode -eq 'Tag') {
57+
#when the mode is tag, show all the potential tags, return the object with: label: tag, value: tag, count: number of templates with that tag, unique only
58+
$Templates = $RawTemplates | Where-Object { $_.Package } | Select-Object -Property Package | ForEach-Object {
59+
$package = $_.Package
60+
[pscustomobject]@{
61+
label = "$($package) ($(($RawTemplates | Where-Object { $_.Package -eq $package }).Count) Templates)"
62+
value = $package
63+
type = 'tag'
64+
templateCount = ($RawTemplates | Where-Object { $_.Package -eq $package }).Count
65+
templates = ($RawTemplates | Where-Object { $_.Package -eq $package } | ForEach-Object {
66+
try {
67+
$JSONData = $_.JSON | ConvertFrom-Json -Depth 100 -ErrorAction SilentlyContinue
68+
$data = $JSONData.RAWJson | ConvertFrom-Json -Depth 100 -ErrorAction SilentlyContinue
69+
$data | Add-Member -NotePropertyName 'displayName' -NotePropertyValue $JSONData.Displayname -Force
70+
$data | Add-Member -NotePropertyName 'description' -NotePropertyValue $JSONData.Description -Force
71+
$data | Add-Member -NotePropertyName 'Type' -NotePropertyValue $JSONData.Type -Force
72+
$data | Add-Member -NotePropertyName 'GUID' -NotePropertyValue $_.RowKey -Force
73+
$data | Add-Member -NotePropertyName 'package' -NotePropertyValue $_.Package -Force
74+
$data
75+
} catch {
76+
77+
}
78+
})
79+
}
80+
} | Sort-Object -Property label -Unique
81+
} else {
82+
$Templates = $RawTemplates.JSON | ForEach-Object { try { ConvertFrom-Json -InputObject $_ -Depth 100 -ErrorAction SilentlyContinue } catch {} }
83+
84+
}
5785
}
5886

5987
if ($Request.query.ID) { $Templates = $Templates | Where-Object -Property guid -EQ $Request.query.id }

0 commit comments

Comments
 (0)