Coding Stephan

Package apps for Intune

In the previous post I explained that you can use Intune to install applications for all you colleagues. In this post I’ll go into packaging apps for Intune

Package an app in seconds

Series: Intune

Packaging apps for Intune

To get apps in Intune you will have to package them. Packaging an app is a matter of downloading the installer, figuring out how to run that installer silently (without user interaction) and then creating a intunewin file from that. And since Microsoft recently has adopted Winget as the new package manager for windows, that seemed like a good place to start. It must have all the details needed to package that app for Intune.

This is how I got started with my new project WingetIntune, as command line tool to download all the needed details from winget and package it for Intune.

Dependency on Windows

Currently this command line app (and the future library) only work on Windows machines. It’s actually using winget for searching and loading some package details. And for now it’s also using the IntuneWinAppUtil to create the intunewin file. I’m planning to remove that dependency in the future, but for now it’s a Windows only tool.

Search for apps using Winget

You can use winget to search for any app, it your want the details for Oh-my-posh you can search for it on Winget by executing this command:

winget search oh-my-posh

which will give you this output:

Name       Id                      Version Match               Source
----------------------------------------------------------------------
oh-my-posh XP8K0HKJFRXGCK          Unknown                     msstore
Oh My Posh JanDeDobbeleer.OhMyPosh 18.5.1  Moniker: oh-my-posh winget

Usage

After you installed the tool, you can package the winget package for Intune by executing this command:

winget-intune package JanDeDobbeleer.OhMyPosh --package-folder c:\packages

This will:

  1. Find the latest version of the package (using the winget show command)
  2. Download the manifest for that package from the winget repo
  3. Download the installer for that package
  4. Downloads the logo for that package
  5. Compute the detection rules for that package (either a script or a msi product code)
  6. Guesses the install command based on the installer type (msi, exe, zip, etc)
  7. Creates a intunewin from the installer (using the IntuneWinAppUtil, which is automatically downloaded)
  8. Creates a readme with the detection rules and install command

Future improvements

Some parts of this tool have a dependency on a Windows executable. Searching for packages starts the winget process, their seems to be a community build rest api but I haven’t looked into that yet. And the packaging part uses the IntuneWinAppUtil, which is a Windows executable. And while it’s hosted at github, Microsoft does not seem to provide the source for this tool.

Having a dependency on closed source executable does not feel like a stable solution. I’m starting the tool in a new process, so the integration is not the best for using in any cloud environment.

Conclusion

I though automatically packaging these apps for Intune was the hardest part of this project. After generating the intunewin files, I thought publishing those files to Intune would be a breeze. But it turns out that’s not the case. I’ll explain that in the next post. Be sure to follow me on Twitter to get notified when I publish that post.