Powershell Function for packaging a Win32App

(code is at the bottom of the page)

This blog is about the powershell function that I wrote for packaging Win32Apps. Normally this would take sometime creating folder and find the tools etc… Now you just only need to supply these 5 parameters:

Preparation/Set Parameters

5 parameters need to entered like this:
The parameters need to be entered without quotes, even when you have spaces in the installers location or the install command.

ApplicationName: This is the name of the application, there are 2 folders being created after this name. I will specify them later on.
InstallerLocation: This is location of the installer this could anywhere on your PC. This file will be copied to the folder that is going to be packaged by the function.
Packaging: This is a boolean value, so you need to enter $True of $False. I have put this in because I want to expand this function to automatically upload the .intunewin file to Intune. In that case it wouldn’t always be necessary to package an app.
InstallCommand: This is the command which triggers the installation of the app. This is often the “appname.exe /silentinstallcommand”. You should check this before running the function.
UninstallCommand: This is the command which triggers the removal of the app. I often use “wmic product where “name like ‘AppName%'” call uninstall”

Packaging Example

The script starts to run. The base folders are created:

A folder is created by the first parameter (ApplicationName). A folder to download and store the IntuneWinAppUtil. Last but not least a folder is created for storing the .intunewin file, the output folder. (A folder with the ApplicationName) is also created in this folder.

The installer is copied to the folder with the ApplicatioName, in this example, Greenshot. Furthermore there are 2 files created. A file called Install.cmd & UnInstall.cmd. These files contain the parameters correspondant with the files.

I have created these generic files so that when the packaged is uploaded to Intune the Install- and Uninstallcommand is always the same.

After that the .intunewin is created in the OutPut\ApplcationName (Greenshot) folder:

Now you are ready to upload the package to Microsoft Intune.

I am planning to expand this script to automatically upload the IntuneWin file Intune, fill the parameters and assign the package. If you want to do so you can add this parameter:

And at the end of the script you need add an “If Statement” to set the upload to Intune in motion. That could be something like this:

This the function that packages the application:

Related Posts

2 thoughts on “Powershell Function for packaging a Win32App

Leave a Reply