Automating Compliance Policies in Microsoft Intune with Powershell

Microsoft has released a number of powershell sample script on github. After playing around with them for a bit I have found some cool and powerful use cases that I want to share. The first one is about creating and reusing compliance policies across multiple customer tenants.  

Let us assume that you have created a set of compliance policies inside a test tenant and have landed on the compliance policies you want to reuse as a baseline for your customers. We have downloaded the Intune Samples scripts from github

Exporting settings

Now we want to move into the folder \CompliancePolicy\ and find and execute the script that is called CompliancePolicy_Export.ps1. The first time we run the script it will as you to log on and  create an access token and ask for permissions on your tenant. This requires you to have the AzureAD v2 powershell module installed.

First logon via Microsoft Intune Powershell

Microsoft Intune Powershell asks to be granted permissions on your tenant

Running the script

So after we have done this, the compliance policies should be in the folder we assigned as JSON files and .csv files. 

Import baseline into customer tenant

Now we are ready to import these settings into any tenant we are implementing or managing. The only thing we need to do is to take the JSON files as input and import them one by one. Of course you could do this even more automated by going through the folder and picking up all the JSON files at once. In my example I am importing them one by one. Take a look at this video to see how this looks when importing the policies into a new tenant.

141 thoughts on “Automating Compliance Policies in Microsoft Intune with Powershell

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.