SCCM client version check bug

Mar 12, 2015 at 3:21 AM
Edited Mar 12, 2015 at 3:23 AM
Hi there,

I've discovered a bug in the checkClientVersion function which occurs if part of the installed version is higher than the subsequent version part.

Assuming that we want to check for a minimum installed version, the following produces an incorrect result:

Minimum version: 4.1.2.3
Installed version : 4.2.1.0

Even though 4.2 > 4.1, x.x.1.0 is detected as being LESS THAN x.x.2.3 so returns false.

Possible fix:
    ' ~~~~~~~~~~~~~~
    ' Compare given SCCM agent version number to the expected "latestClientVersion" value defined in config.ini.
    ' Return true if installedVersion is greater than or equal to correctClientVersion
    Function checkClientVersion(installedVersion)

      If CBool(Instr(installedVersion, ".")) Then
          arrThisClientVersion = Split(installedVersion,".")
          arrCorrectClientVersion = Split(correctClientVersion,".")

          If UBound(arrThisClientVersion) > 0 Then
                For i = 0 To UBound(arrThisClientVersion)
                    If arrThisClientVersion(i) > arrCorrectClientVersion(i) Then
                        checkClientVersion = True
                        Exit Function
                    ElseIf arrThisClientVersion(i) < arrCorrectClientVersion(i) Then
                        checkClientVersion = False
                        Exit Function
                    End If
                Next
            Else
                Exit Function
            End If
            
            checkClientVersion = True
        Else
            checkClientVersion = False
        End If
      
    End Function