Upload custom iOS Intune Configuration via Graph API

A customer is right now migrating from a Thirdparty MDM solution to Microsoft Intune. He has a custom iOS IMAP configuration for round about 30 users and do not wanted them to migrate every policy manually so we created a quick Powershell script which is changing the user values inside the XML and uploads them as a configuration via the Intune Graph API.
The interesting part was, that these are Exchange Online Shared mailboxes which have to be configured with the primary user’s UPN account.

So I have taken the DeviceConfiguration_Add.ps1 Powershell Script from the Intune Github Sample Page and added/changed the following things.
The full script is available as a GIST or on the bottom of the blog post.

  • Added a parameter named $upn which is getting the User Principal Name for which user the policy should be built. Line 14-17


  • Added a region called “Build XML” where I am replacing some Usernames with variables. Line 320 – 408


  • Finally a region called “Build JSON Payload” where I encoding the UTF8 XML Payload to a BASE64 string and building the JSON request. Line 410 – 425


    This is my first public Powershell script, so if there are any requests to make it portable and do some error checks I am happy about your feedback.


And here is the full script.