20141008_105129Introduction

It’s Monday morning.  You’ve been at work for approximately one hour, quietly struggling to catch-up on a backlog of work piled on you after a colleague was transferred out, and another took a higher-paying offer elsewhere.  You need to deploy some applications using Microsoft System Center Configuration Manager 2012 R2 (long inhale on that one, you’ve earned it).  The first application apparently requires every client to have IE9 or later or it won’t install.  Rather than let the app do it’s own detecting and failing, you decide to see what SCCM can do for requirements.

You create the Application object, and the Deployment Type, and then drill into the Requirements part.   You scour the list, but there’s no built-in options for verifying anything directly related to IE versions.  You can try bending the Registry option, but it’s going to return a static value and running the limited Boolean operations on it from the drop-down list don’t cut it.

One solution is to use the script method for detecting the version of IE.  Keep in mind two (2) important aspects of this:

  1. The script method returns a string result.  If you’re using WSH/VBScript, it requires the wscript.echo method to shovel the results back to SCCM because it’s not built to handle wscript.quit(value) as a pipeline return.
  2. The condition check needs to return a distinct value if the installed IE version is greater than 8.x.

Here’s one example:

'****************************************************************
' Filename..: gc_ie9_or_newer.vbs
' Author....: skatterbrainz.wordpress.com (that's me)
' Date......: 11/19/2014
' Purpose...: returns "TRUE" if IE 9 or newer. Otherwise "FALSE"
'****************************************************************
Option Explicit
Const regPath = _
  "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer"
Const valName = "svcVersion"

Dim objShell, result, parse, vmajor

Set objShell = CreateObject("Wscript.Shell")
On Error Resume Next
result = objShell.RegRead(regPath & "\" & valName)
If err.Number = 0 Then
  parse = Split(result,".")
  vmajor = parse(0)
  If vmajor > 8 Then
    wscript.echo "TRUE"
  Else
    wscript.echo "FALSE"
  End If
End If

Staring blank at this ugly code, you can see that I’m just querying a basic registry value, and parsing it out.  The version number is stored in common SDLC major.minor.really-minor.way-down-and-dirty-minor format.  Example: 9.1021.23.01 and so forth (I made that one up for demonstration purposes only)

Using the ancient “Split()” function, I parse the string on each dot “.” and get an array.  The first element in the array is counted from zero (0), so “Parse(0)” returns the first part, which happens to be the “major” version component.  I could explicitly cast that into a numeric value using CDBL or CINT, but VBScript is drunk enough to see “8” and think it’s a hot-looking number 8, and let’s it into the party.  Once it’s in the door (e.g. “value is greater than 8”) we return “TRUE”.  Then back in the SCCM form, we tell it to look for “TRUE” as the qualifying result.

sccm_dep_reqt

(psssst…. to add another requirement, click the “Add…” button)

I know you can skin this catfish a dozen other ways, so this just makes it thirteen ways.

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s