Description
Microsoft Intune now supports using a as the installer for Win32 apps. Instead of specifying a command line, you upload a script.
I put together a template (install and uninstall) that lets you:
- Install or uninstall an application (MSI or EXE)
- Copy or remove files to or from any directory
- Add or remove registry settings
The scripts handle both SYSTEM and user context. When running as SYSTEM, file and HKCU registry operations are applied to all existing user profiles on the device.
The template is available on GitHub:
Read the full blog post here:
PowerShell
The template consists of two scripts – one for install and one for uninstall. Both follow the same structure with a configuration section at the top.
Install script:
- Runs the installer (MSI or EXE)
- Copies files to destination folders
- Applies registry settings
Uninstall script:
- Runs the uninstaller (MSI or EXE)
- Removes the copied files
- Removes the registry settings
When running as SYSTEM, both scripts apply file and registry operations to all user profiles on the device. Both AD (S-1-5-21-*) and Entra ID (S-1-12-1-*) accounts are picked up.
Microsoft Intune
To use the PowerShell script installer, create a Win32 app as usual but select PowerShell script instead of a command line. You still need to package your app files with the – but the scripts are uploaded separately in the portal.
Your .intunewin package should contain:
- The installer file (MSI and/or EXE)
- Any files you want to copy
The install and uninstall scripts are uploaded directly in Intune.
Scripts are limited to 50 KB, must run silently, and run in the same context as the app installer (SYSTEM or user).
Logging
Both scripts write to a log file in the Intune Management Extension logs folder:
%ProgramData%\Microsoft\IntuneManagementExtension\Logs\<AppName>-Install.log %ProgramData%\Microsoft\IntuneManagementExtension\Logs\<AppName>-Uninstall.log
MSI installers get their own detailed log as well.
32-bit gotcha
$env:ProgramFiles resolves to C:\Program Files (x86) instead of C:\Program Files. If you reference the Program Files folder anywhere in your scripts, whether it’s for file copy destinations, uninstaller paths, or anything else, use $env:ProgramW6432
# Won't work - resolves to Program Files (x86)
$UninstallerFile = "$env:ProgramFiles\Notepad++\uninstall.exe"
# Works - always resolves to C:\Program Files
$UninstallerFile = "$env:ProgramW6432\Notepad++\uninstall.exe"
Also worth noting: the “Run script as 32-bit process on 64-bit clients” toggle doesn’t seem to have any effect for the PowerShell script installer. Scripts run as 32-bit regardless. This means HKLM registry writes end up in HKLM:\SOFTWARE\WOW6432Node. HKCU writes are not