All scripts
Automation 285
Backup-IntuneConfigurationProfiles
Exports every device configuration profile in Intune to individual JSON files, giving you a restore point before making bulk configuration changes.
Backup-IntuneConfigurationProfiles.ps1
<#
.SYNOPSIS
Backs up all Intune device configuration profiles to JSON.
.DESCRIPTION
Exports every device configuration profile's full settings to an
individual timestamped JSON file, giving you a restore reference
before making bulk configuration changes across the fleet.
.PARAMETER BackupPath
Folder to write the backup files to. Defaults to the current directory.
.EXAMPLE
.\Backup-IntuneConfigurationProfiles.ps1 -BackupPath C:\Backups\Intune
.NOTES
Requires Microsoft.Graph.DeviceManagement with an active
Connect-MgGraph session.
.AUTHOR
Shehryar Hassan
#>
param(
[string]$BackupPath = (Get-Location).Path
)
$stamp = Get-Date -Format "yyyy-MM-dd_HHmmss"
$folder = Join-Path $BackupPath "IntuneConfigProfiles_$stamp"
New-Item -ItemType Directory -Path $folder -Force | Out-Null
$profiles = Get-MgDeviceManagementDeviceConfiguration -All
foreach ($profile in $profiles) {
$safeName = $profile.DisplayName -replace "[:\\/*?<>|]", "_"
$file = Join-Path $folder "$safeName.json"
$profile | ConvertTo-Json -Depth 8 | Out-File -FilePath $file -Encoding utf8
}
Write-Host "Backed up $($profiles.Count) configuration profile(s) to $folder" -ForegroundColor Cyan
Read it before you run it, and test in a safe tenant first.