Use a Custom Script to detect the presence of an Application Deployment Type in SCCM 2012

Purpose: a fundamental thing to know when creating a Custom Detection script in SCCM 2012

Creating a custom application detection script will require one thing to be understood before you begin scripting: How the SCCM understands that the application is installed or is not installed. You might think that if your script is returning true or false, or if it is returning zero or one – you would have found the syntax, but you are wrong.

Application Deployment – Custom Detection Method

Custom Detection Script: VBScript (VBS)
Application Detected When VBS echos anything. You can Echo “Failed” or “Success” or “Jacks Hairy Monkey is climbing the trees again” and the application is detected.
Example:
wscript.echo “Success”
Application Not Detected Do not echo anything, and the application is considered not found.
Example:
wscript.quit
Custom Detection Script: PowerShell (PS)
Application Detected When PS returns anything.

Example:
{return $true}
Application Not Detected Do not return anything, and the application is considered not found.
Custom Detection Script: JScript (JS)

Have not done any SCCM work with this script language, so will assume one of the previous will work.

5 Thoughts on “Use a Custom Script to detect the presence of an Application Deployment Type in SCCM 2012

  1. Hajime on June 6, 2013 at 11:17 said:

    Hi, What if the script returns some error message? Does the sccm consider that the application is detected in this case?

    For example, If I execute Get-Process notepad when notepad is running, it returns

    PS E:\> get-process notepad

    Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
    ——- —— —– —– —– —— — ———–
    98 10 2624 10612 121 0.02 4136 notepad

    On the other hand, if the notepad is NOT running, it returns

    PS E:\> get-process notepad
    get-process : Cannot find a process with the name “notepad”. Verify the process name and call the cmdlet again.
    At line:1 char:1
    + get-process notepad
    + ~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : ObjectNotFound: (notepad:String) [Get-Process], ProcessCommandException
    + FullyQualifiedErrorId : NoProcessFoundForGivenName,Microsoft.PowerShell.Commands.GetProcessCommand

    In both cases, there is a return. What do you mean by do not echo anything?

  2. Jyri Lehtonen on June 6, 2013 at 16:52 said:

    Hi,

    I believe you need to use condition:
    if (Get-Process | ?{$_.Name -eq “notepad”}) { Return 0 } else { }

    Then you will return something if the process for notepad is detected (Application Detected as: Installed), but will not do anything if the process is not detected (Application Detected: Not installed).

    • Hajime on June 7, 2013 at 14:55 said:

      Hi,

      Thank you for the timely response. I now understand how I should use the powershell script in the detection method. Appreciate your variable information.

  3. Joshua on August 15, 2013 at 00:13 said:

    wow thanks for this post, I was going nuts over how the detection works does it need a true/false return value or if it needs a 0/1 value….

    thanks for this again. How did you figure it out? is this documented somewhere?

  4. Jyri Lehtonen on August 15, 2013 at 09:31 said:

    Hi Joshua,

    I could not find it either from any offical or unoffical documentation.
    But I had a dire need to get it working so I spent time figuring it out by trial and error.
    The workstation SCCM logs were helpful as I recall.

Leave a Reply

Your email address will not be published. Required fields are marked *


five + = ten

Post Navigation