PowerShell Detection Method for SCCM 1

PowerShell Detection Method for SCCM

There have been a lot of discussion how to write a proper PowerShell detection method and how to tell Configuration Manager if the application was detected. This post explains how a PowerShell detection method for sccm works and what it should return if the applications is detected as installed.

Detection Methods

Detection methods are used by Configuration Manager to detect if an application is present on the system after the installer completed successfully. Back in the days, SCCM would install a package and everything was good as far as SCCM was concerned as long as the installer returned a good exit code. We know from experience to not trust that as an installation script could run successfully even if several steps inside the script failed. So Microsoft came up with detection methods.

PowerShell Detection Method For SCCM

The only way Configuration Manager knows if an application was detected or not is if the PowerShell detection method returns “Installed”. If it returns something else, Configuration Manager interprets that as the application is not detected. Returning $true and $false may not work every time and you might experience that your application is not detected even if it is.

Here is a PowerShell detection method for an application called PosPay that stores its version number in a file named “version”. The PowerShell script reads out the content of that file and returns “Installed” if it has the correct version after installation or upgrade. I use this as a template for my PowerShell detection methods that reads version information from a file.

# Version to detect
$version = "4.15.4"
# Path to file
$path = "c:\Program Files\PosPay\version"

$appVersion = get-content -Path $path
if ($appVersion.contains($version)) {
    Write-Host "Installed"
else {

You can use PowerShell in many other ways to detect if your application was properly installed, like checking for specific registry keys or verify license information. Just make sure your script returns “Installed” when the application is detected and installed the way you want it.

Anders Rødland

Anders Rødland started his IT career in 2006. My main focus is MS Configuration Manager and client management, and I have passed 17 Microsoft certifications since then. My main expertise is on client management with Microsoft Endpoint Manager: Intune and Configuration Manager. I also do a lot of work on the security side with Microsoft Defender for Endpoint. In addition to my Microsoft certification, I also have an ITIL v3 Foundation certification. This is my private blog and do not represent my employer. I use this to share information that I find useful. Sharing is caring.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.