Global Conditions and VBScript

Currently my days are filled of migrating previous heavy-duty VBScripts that have provided what SCCM 2007 doesn’t have, but SCCM 2012 offers in the Application Model.

A major part of replacing VBScripts are Global Conditions within Configuration Manager 2012. And as the original script is in VBScript along with the fact that the client base is Windows XP to some extent – VBScript will prevail a bit longer even though its now wrapped within a Global Condition.

What I should have done from the start was to read about Global Conditons in the official Technet-site. There are a few gotchas and I realized that even more of the old code could have been moved to native functionality. For example – File checks can traverse the environment variable %USERPROFILE% and effectively check for a file (or folder) in all users folders on a specific target.

Now, I didn’t do this. So therefore I suffered for a day.

As the VBScripts had already been used in production I knew the quality of them was quite high in terms of achieving what I wanted – stripping them down to a specific function (remove installs and only perform a specific check for example) was easy. My first belief was that the exit-code of the script mattered. This resulted in some odd experiences, because everything ended with error.

Reading the documentation revealed that the exit-code wasn’t as relevant (should always be 0)

The value returned by the script will be used to assess the compliance of the global condition. For example, when you use VBScript, you could use the command WScript.Echo Result to return the Result variable value to the global condition.

Great – I can perform an echo! Well, obviously  this is the way togo – howelse to return a string for example?

As my initial tests involved the check that could only return true or false that was what I returned (a boolean value). VBScript outputs –1 as true. So when my boolean variable was true – the output was –1. However, SCCM was none the wiser.

Result (from DcmWmiProvider.log )

ScriptProvider::ReadDiscoveryInformation – reading discovery script definition    ScriptProvider   8/20/2013 12:41:57 AM  1428 (0x0594)

ScriptProvider::ReadDiscoveryInformation – ScriptType: 1           ScriptProvider   8/20/2013 12:41:57 AM  1428 (0x0594)

ConvertToVariant failed to convert value:-1 to Type:Boolean (0x80041005).          ScriptProvider   8/20/2013 12:41:57 AM  1428 (0x0594)

Failed in discovering instance.

Type mismatch (Error: 80041005; Source: WMI)  ScriptProvider   8/20/2013 12:41:57 AM  1428 (0x0594)

This failed completely.

If the output instead becomes the string “true” or “false (Result = “True”) – the output is handled by SCCM and can easily be converted into a Boolean (which makes the SCCM admins life my easier).

Unfortunately – the successful use of a script has no output in any logs as far as I have seen.

2 thoughts on “Global Conditions and VBScript

  1. Thai Diep Reply

    I’m configuring the Global conditions with vbscript. As I read your post, in the end, do you have any solution to detect the return of the vbscript ?
    Please advise.

    • nickekallen Post authorReply

      My primary concern is with boolean values. You could try to use a string

Leave a Reply

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