Skip to content

Commit 1f03dc4

Browse files
Merge pull request KelvinTegelaar#1920 from kris6673/intunecollection-update
chore: Add script to regenerate intuneCollection.json and also update it
2 parents 2d96010 + 3ef2df3 commit 1f03dc4

2 files changed

Lines changed: 66065 additions & 40507 deletions

File tree

Tools/Update-IntuneCollection.ps1

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
<#
2+
.SYNOPSIS
3+
Regenerates the intuneCollection.json lookup file from the Microsoft Graph API.
4+
5+
.DESCRIPTION
6+
Queries the Microsoft Graph beta endpoint for all Intune device management
7+
configuration setting definitions and writes the result to intuneCollection.json
8+
in both the CIPP-API root and CIPP/src/data directories.
9+
10+
The resulting file is used by Compare-CIPPIntuneObject.ps1 (backend) and
11+
CippTemplateFieldRenderer.jsx / CippJSONView.jsx (frontend) to translate
12+
raw settingDefinitionIds into human-readable display names.
13+
14+
Must be run from the "Tools" folder in the CIPP-API project, with
15+
Initialize-DevEnvironment.ps1 already dot-sourced (or it will be loaded
16+
automatically). Requires a valid CIPP-managed TenantId to obtain a Graph token.
17+
18+
.PARAMETER TenantId
19+
A tenant domain or GUID that CIPP manages. Used only to obtain a Graph
20+
authentication token — the configurationSettings endpoint returns Microsoft's
21+
global catalog, not tenant-specific data.
22+
23+
.EXAMPLE
24+
# From the Tools folder, after initialising your dev environment:
25+
. .\Initialize-DevEnvironment.ps1
26+
.\Update-IntuneCollection.ps1 -TenantId contoso.onmicrosoft.com
27+
28+
.NOTES
29+
Permissions required: DeviceManagementConfiguration.Read.All
30+
#>
31+
32+
[CmdletBinding()]
33+
param(
34+
[Parameter(Mandatory)]
35+
[string]$TenantId
36+
)
37+
38+
Set-StrictMode -Version Latest
39+
$ErrorActionPreference = 'Stop'
40+
41+
# ---------------------------------------------------------------------------
42+
# Ensure the CIPP module is loaded
43+
# ---------------------------------------------------------------------------
44+
if (-not (Get-Module -Name CIPPCore)) {
45+
Write-Host 'CIPPCore not loaded — running Initialize-DevEnvironment.ps1...' -ForegroundColor Yellow
46+
. (Join-Path $PSScriptRoot 'Initialize-DevEnvironment.ps1')
47+
}
48+
49+
# ---------------------------------------------------------------------------
50+
# Fetch all configurationSettings (New-GraphGetRequest auto-paginates)
51+
# ---------------------------------------------------------------------------
52+
Write-Host 'Fetching Intune configuration settings (this may take a while)...' -ForegroundColor Yellow
53+
54+
$allSettings = New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/deviceManagement/configurationSettings' -tenantid $TenantId -NoAuthCheck $true
55+
56+
Write-Host "Total settings fetched: $($allSettings.Count)" -ForegroundColor Green
57+
58+
# ---------------------------------------------------------------------------
59+
# Transform to the shape expected by CIPP
60+
# Shape: [{ id, displayName, options: [{id, displayName, description}] | null }]
61+
# ---------------------------------------------------------------------------
62+
Write-Host 'Transforming data...' -ForegroundColor Yellow
63+
64+
$collection = $allSettings | Sort-Object -Property id | ForEach-Object {
65+
$rawOptions = $_.PSObject.Properties['options']?.Value
66+
$options = if ($rawOptions -and $rawOptions.Count -gt 0) {
67+
$rawOptions | ForEach-Object {
68+
[PSCustomObject]@{
69+
id = $_.PSObject.Properties['itemId']?.Value
70+
displayName = $_.PSObject.Properties['displayName']?.Value
71+
description = $_.PSObject.Properties['description']?.Value
72+
}
73+
}
74+
} else {
75+
$null
76+
}
77+
78+
[PSCustomObject]@{
79+
id = $_.id
80+
displayName = $_.displayName
81+
options = $options
82+
}
83+
}
84+
85+
# ---------------------------------------------------------------------------
86+
# Write output files
87+
# ---------------------------------------------------------------------------
88+
Set-Location $PSScriptRoot
89+
90+
$json = $collection | ConvertTo-Json -Depth 5
91+
92+
# CIPP-API root (used by Compare-CIPPIntuneObject.ps1 at runtime)
93+
$apiPath = Join-Path $PSScriptRoot '..\intuneCollection.json'
94+
$json | Set-Content -Path $apiPath -Encoding utf8NoBOM
95+
Write-Host "Written: $(Resolve-Path $apiPath)" -ForegroundColor Green
96+
97+
# CIPP frontend src/data (used by the React UI)
98+
$frontendPath = Join-Path $PSScriptRoot '..\..\CIPP\src\data\intuneCollection.json'
99+
if (Test-Path (Split-Path $frontendPath)) {
100+
$json | Set-Content -Path $frontendPath -Encoding utf8NoBOM
101+
Write-Host "Written: $(Resolve-Path $frontendPath)" -ForegroundColor Green
102+
} else {
103+
Write-Host "CIPP frontend path not found — skipping: $frontendPath" -ForegroundColor Yellow
104+
Write-Host "Copy $(Resolve-Path $apiPath) manually to your CIPP/src/data/ directory." -ForegroundColor Yellow
105+
}
106+
107+
Write-Host "`nDone. $($collection.Count) settings written to intuneCollection.json." -ForegroundColor Green

0 commit comments

Comments
 (0)