You may have a requirement to export or import Microsoft Intune policies while working on tenant migration or setting up a new environment. The export and import can save a lots of time when working on tenant migration or consolidation. You can also have standard set of policies in JSON to quickly import while working on a new tenant setup. The imported policy can be further customized as per organization requirements.
However, there are no such options available in Intune admin center to export or import policy settings. You need to work with Microsoft Graph / Microsoft Graph PowerShell API for this. Fortunately, prebuilt PowerShell scripts are available in Github repository and the process of using these scripts are straighforward.
In this blog post, we will discuss how to export and import Device Compliance Policies using PowerShell Sample Scripts available in Github.
How to Export Device Compliance Policies in JSON File
Follow the below steps to export Device Compliance Policies in JSON file.
- Download the Intune PowerShell scripts from PowerShell Intune Samples and extract all files to local drive.
- Run PowerShell as an Administrator
- Set PowerShell execution Policy to ByPass ( Set-ExecutionPolicy bypass )
- Install PowerShell AzureAD and Microsoft Graph Module if not already installed
- Change the location to the “CompliancePolicy” under “Powershell-intune-samples-master”
- Run the script .\CompliancePolicy_Export.ps1
- If prompted, login with your Azure AD / Entra ID credential.
- Specify a path to export the policy data.
You can see the export progress in PowerShell window. The script export each compliance policy in a separate JSON and CSV file.
You can view the exported files in File Explorer.
How to Import Device Compliance Policies from JSON File
Now the Device compliance policies have been exported in separate JSON files. We can import them in another tenant one by one using CompliancePolicy_FromJSON.ps1 script.
If you are trying the import from different machines than where you exported the files then you may need to repeat the initial steps we followed for export. Please note that imported policies remain unassigned. You need to assign them to device , users or groups to move them to production.
Follow the below steps to import the policies to Intune tenant.
- Change the directory to “CompliancePolicy” folder and run the script .\CompliancePolicy_import_FromJSON.ps1
- Specify the JSON file name with full path which you want to import.
The script will show the message that policy was found and it shows the details on screen.
The script will then import the settings from JSON file to Intune tenant.
You can validate the same form Intune tenant where you have imported the settings. Since, the testing was done on same tenant, you can see a new file created with same name. The older one was renamed as Old.
- How To Export Serial number of Multiple Devices using PowerShell SDK for Intune Graph API
- How to Export Managed Device Details from Intune
- Export Device Configuration Profiles List in Intune
- How to Export Settings Catalog Policy in Intune
- Export and Import Device Compliance Policies in Intune
- How to Export Device Configuration Profiles in Intune
- How to Export Endpoint Security Policies in Intune
Subscribe to Techuisitive Newsletter
Be the first to know about our new blog posts. Get our newsletters directly in your inbox and stay up to date about Modern Desktop Management technologies & news.