Automate the creation of Android Apps in Microsoft Intune
A few weeks ago the Intune team released a preview of the Intune Powershell SDK (Microsoft Intune Powershell preview releases! – Orbid365), after the release I started to experiment with these cmdlets.
Adding iOS apps in Intune is very simple because you can browse the iOS store directly through the Intune portal, adding Android apps is a lot more time consuming. You have to fill-in all the App Information yourself.
That’s why I decided to create a script that automates the addition of Android Applications into Intune. The script adds Android apps through a CSV-file and I decided to take the newly generated Powershell CMDlets for a testrun!
The CSV file has the following headers:
- Name
- URL
- Publisher
- Description
- MininumAndroidVersion
- Icon
The script can be split up into 4 different steps
- Importing the Intune Module
- Import the Applications CSV
- Connect to MS Graph
- Add the applications
If you have never used the Intune SDK before, you need to run the Connect command with the AdminConsent parameter before executing the script
Connect-MSGraph -AdminConsent
This accepts the permissions that the SDK requires to configure your Intune environment.
Minimum Android Version
During the process of writing the script, I ran into a few problems.The command for adding applications is
New-DeviceAppManagement_MobileApps
This requires the –minimumSupportedOperatingSystem parameter which needs a AndroidMinimumOperatingSystemObject that specifies what the minimum Android OS version should be for the specific application. A AndroidMinimumOperatingSystemObject can be created through the command
New-AndroidMinimumOperatingSystemObject
This command has several parameters:
Property | Type | Description |
---|---|---|
v4_0 | Boolean | Version 4.0 or later. |
v4_0_3 | Boolean | Version 4.0.3 or later. |
v4_1 | Boolean | Version 4.1 or later. |
v4_2 | Boolean | Version 4.2 or later. |
v4_3 | Boolean | Version 4.3 or later. |
v4_4 | Boolean | Version 4.4 or later. |
v5_0 | Boolean | Version 5.0 or later. |
v5_1 | Boolean | Version 5.1 or later. |
Source: Microsoft Graph Documentation
The CSV has a parameter called ‘MininumAndroidVersion’, which has the form ‘4_0’. If you try to use the command:
New-AndroidMinimumOperatingSystemObject -application.MininumAndroidVersion $true
where ‘application.MininumAndroidVersion’ is 4.0. Powershell throws an exception because it sees the parametername as a string. The wordaround for this is to create a hash table with the parameter and provide this hash table to the command.
The code for this looks like this:
$parameters = @{"v$($application.MininumAndroidVersion)" = $True} $androidVersion = New-AndroidMinimumOperatingSystemObject @parameter
Icons
This script is currently configured to use icons that are stored locally on the computer. If you want the script to download the icon from the web, just change line 169 to
$iconBytes = Invoke-Webrequest $application.Icon
Script
The script full script can be found on my Github account. Download it and start automating! Github Link
I am a 22-year old cloud and automation enthusiast. My main focus is EMS, Powershell and Azure. My scripts can be found through my GitHub account: https://github.com/thijslecomte. I am currently blogging at http://365bythijs.be