Kaffeeundcode
Script Library
PowerShell 11.12.2025

Script Workspace

Export IntuneJSON

Review the purpose, inspect the code, then test it safely in your own tenant.

85_Export-IntuneJSON.ps1

<#
.SYNOPSIS
    Exports specific Intune Configuration to JSON.
    
.DESCRIPTION
    Dumps a Policy object to JSON for version control.
    
.NOTES
    File Name: 85_Export-IntuneJSON.ps1
    Author: Mattia Cirillo
    Version: 1.0
#>

param(
    [string]$PolicyId
)

Connect-MgGraph -Scopes "DeviceManagementConfiguration.Read.All"

$Policy = Get-MgDeviceManagementDeviceCompliancePolicy -DeviceCompliancePolicyId $PolicyId
if ($Policy) {
    $Policy | ConvertTo-Json -Depth 5
}