Skip to content
Menu

Back up the Whole Intune Configuration to JSON

Reads six kinds of Intune policy from one client tenant and writes each one to its own JSON file in a new dated folder, with an index. Nothing in the tenant changes.

Back up the whole Intune configuration to JSON is free for members.

Enter your email to create your free account and get the file.

We'll email you the script and the weekly MSP Outpost email. Unsubscribe anytime. Privacy policy.

Already a member? Sign in.

Be the first to review Back up the whole Intune configuration to JSON. Tell other MSPs how it worked for you.

Write a Review

LanguagePowerShell
Runs onWindows 10, 11, Server 2016+, with the app certificate; runs as SYSTEM or a user
NeedsPowerShell 5.1; Graph: DeviceManagementConfiguration.Read.All, DeviceManagementApps.Read.All; Intune
Changes thingsChanges what it runs on

What It Does

The script signs in to one client tenant as your app registration and reads six categories of Intune configuration through Microsoft Graph. Configuration profiles and compliance policies are read from the beta endpoint: the v1.0 list silently leaves out profile types it does not know, such as a Wi-Fi profile. Settings catalog and endpoint security policies are read with their settings.

Each object is written to its own JSON file, named after the policy and its ID, under a folder in OutputFolder stamped with the UTC time. The index lists the objects exported in that run. The script leaves folders with older timestamps alone. A dry run reads the selected categories and writes no backup files.

Any property whose name ends in secret, password, passphrase, preSharedKey or privateKey is replaced with a marker before writing. Microsoft does not return some of these values at all. The files still hold tenant details, so keep the folder as private as the tenant.

If a category cannot be read, the run stops before writing the backup files. Name the category in SkipCategories to leave it out. The export omits assignments, apps, scripts, enrollment restrictions and status pages, compliance scheduled actions, Autopilot profiles, and security baselines outside the endpoint security intents. Use the files to compare and rebuild. There is no restore operation.

Before You Run It

  • Create an app registration in the client tenant with the Graph application permissions DeviceManagementConfiguration.Read.All and DeviceManagementApps.Read.All and give admin consent.
  • The tenant needs an Intune licence.
  • Run it on a server or PC you trust with the client's configuration; the default folder is restricted to administrators.

Type and Risk

  • Type: Action. It makes its change, checks the change worked and says what changed. It exits 0, or 2 when it could not do the job.
  • Risk: Low. Set DryRun=true, or run it with -WhatIf, to list every change without making any.
  • What it changes: Writes JSON files and an index under OutputFolder; changes nothing in the tenant.
  • Restart: It never restarts the machine.
  • Typical run: Under 10 minutes (longer for hundreds of policies).
  • Example answer: "Backed up 143 Intune object(s) in 6 categories (index.json lists every file); 2 secret field(s) removed"
  • Tested before listing with Windows PowerShell 5.1, run as SYSTEM, against its own test cases and a Microsoft 365 Business Premium test tenant.

Inputs

Pass an input as an argument (-Name value), as an environment variable with the same name, which is how most RMMs pass script variables, or change its default in the param() block at the top of the script. An argument wins over an environment variable, which wins over the default.

  • TenantId: The tenant ID (a GUID) or a domain such as contoso.onmicrosoft.com.
  • ClientId: The app registration's Application (client) ID, a GUID.
  • CertificateThumbprint: Thumbprint of the app's certificate (with its private key) in LocalMachine\My or CurrentUser\My on this computer. Leave empty only if you use the ClientSecret environment variable.
  • OutputFolder: Folder that receives one new time-stamped sub-folder per run. Default: IntuneBackup under the MSP Outpost data folder (ProgramData\MSPOutpost\IntuneBackup).
  • SkipCategories: Categories to leave out, separated by comma, semicolon or new line: DeviceConfigurations, CompliancePolicies, SettingsCatalog, EndpointSecurityIntents, AppProtectionPolicies, AssignmentFilters. Default empty (all).

Every script also takes DryRun, OutputFormat (Text, Answer, Json or Csv), ExportPath and ResultField, which writes the answer to an RMM custom field.

License

Provided "as is" under the MIT License, without warranty of any kind. Test before production use. MSP Outpost and User First Digital Inc. accept no liability for any damage or loss.

The Script

invoke-intune-config-backup.ps1 · 1097 lines · 61 KB

Free for Members

Create a free account or sign in to read, copy and download this script.

Welcome Back

Sign in to your MSP Outpost account.