Intune allows to automatically have software installed on target devices. I found a nice write-up on using this in conjunction with Chocolatey, but realized it could be made much easier. First we’ll prepare the files locally which needs to be done only once, instead of for each application.

## Prepare Chocolatey

The following steps depend on Chocolatey, so first follow the previously mentioned write-up on how to install that through Intune.

## The script

Save the script below as install.ps1 in an empty directory, and download IntuneWinAppUtil.exe into that directory as well.

  1 2 3 4 5 6 7 8 9 10  param( [string]$package = "", [switch]$uninstall = $false ) if ($uninstall) { choco uninstall $package -y } else { choco upgrade$package -y } 

upgrade will install the package if it isn’t yet installed. Two fish.

You can use this script directly by running ./install.ps1 <package name> [-uninstall]. We’ll use Intune to automate installation of packages.

Now let’s create a generic .intunewin file for all our chocolatey apps. In the directory run the following in Powershell:

 1  .\IntuneWinAppUtil.exe -c .\ -s install.ps1 -o .\ 

This creates an .intunewin file which we can re-use in Intune for each application we wish to install using Chocolatey.

## Intune apps

When creating an Intune app, set it as a Windown app (Win32) and during the wizard set the install command to

 1  powershell.exe -executionpolicy bypass .\install.ps1 

And the uninstall command to

 1  powershell.exe -executionpolicy bypass .\install.ps1 -uninstall 

And make sure to set Chocolatey as a dependency.