IntuneWinAppUtil GUI detection helpers
Get-IntuneFileVersion
Command-line helper that returns the FileVersion of a file, the value used by Intune file-based detection rules (File or folder rule, Detection method: String (version)):
Get-IntuneFileVersion -Path 'C:\Program Files\Contoso\Agent\ContosoAgent.exe'
# 4.2.0.118
- Returns only the FileVersion string. It works on any file that carries version information (EXE, DLL, ...); for files without it the result is empty.
- Throws if the path does not exist or is a folder.
-Pathis positional, soGet-IntuneFileVersion .\ContosoAgent.exeworks too.
Read the version from the installed file on a reference machine, not from the installer, because the two often differ.
Intune detection script
Scripts/Intune_CheckAppInstallation.ps1 is a starting point for a custom detection script in a Win32 app. It looks for an executable under both %ProgramFiles% and %ProgramFiles(x86)% and, optionally, checks a minimum version.
- Download the script and set
$searchPathto the executable path relative to Program Files:$searchPath = "Contoso\Agent\ContosoAgent.exe" - Near the end of the script, decide whether a minimum version is required:
$status = Get-AppStatus -MinimumVersion "4.2.0.0" # installed and at least 4.2.0.0$status = Get-AppStatus # installed, any version
- In the Intune app, under Detection rules, choose Use a custom detection script, upload the script and set Run script as 32-bit process on 64-bit clients to No.
How it behaves:
- It reads
FileVersion, orProductVersionwhen FileVersion is empty. - Versions are normalised before comparing: non-numeric characters are dropped and only the first four parts are kept, so
R25.1.164.0.0becomes25.1.164.0. - Exit code
0with a message on standard output when the app is found and meets the minimum version; exit code1when it is missing or older. Intune treats the app as installed only with exit code0and some output. - The message (
App detected. Version: ...,App detected but version below minimum requirement,App NOT detected.) is written to the Intune Management Extension log, which helps when troubleshooting.