SCCM Global Condition Setup

TGH Featured Image Wordcloud

I had been given a task to build a Software Catalog application where Outlook must be closed to allow the successful installation of the software. We had previously just packaged the software and made it available to the Software Catalog with a message stating that users must first shut down Outlook before attempting to run the installation.

However, like most users, they ignored the message, left Outlook open, ran the software installation and then complained when the software wasn’t immediately available to them!
So, the task was fairly simple, setup the Software Catalog application so that if a user had Outlook open and they tried to run the application installation, it would fail, if they had Outlook closed, it would run.
I started to come up with some weird and wonderful methods of doing this involving batch files and other such ways, but then I started to think in more simple terms – Global Conditioning and Powershell.
First, you need to use Powershell to identify the process that you want to check is running or not. To do this (and using the example of Outlook for this purposes but this can be used for any running process…), start up Outlook to ensure it is a running process. Then, go into Powershell and type in the following command:

 get-process  
This will now list all the running processes on your machine, if you look down the list, you will find the process name for Outlook, which conveniently is called OUTLOOK (obviously not all process will be as easy to find..):

Once you have the name of the process you are trying to work with, you can now use Powershell to output a true or false value for if that process is running on the target machine or not. So, for a quick demo, in Powershell (with Outlook still open) type in the following command:

 [bool] (get-process OUTLOOK -ea 0)  

This should now return a value of: True

If you close Outlook down and run the command again, you should see that it now returns a False value.

So, now that we know how to use Powershell to return a true or false value, we can create a Global Condition in SCCM.

To do this, go into your SCCM console > Software Library > Global Conditions. You can then create a new Global Condition. You should then complete the settings as you wish, but you must have the Setting Type as Script and the Data Type as Boolean. Once you are happy with your setup, click the Add Script Button:

You should then ensure that you select Windows Powershell and enter the script that we used earlier to report if the variable is True or False:

You can now click the OK buttons to save your new custom Global Condition.
Now that you have your new Global Condition, you can use it as a Requirement setting in your applications. This is a slightly strange example but hopefully you will understand, but if you wanted to make 7-Zip available in your Software Catalog, but you wanted to ensure that Outlook was not open before allowing the software to run, you should build your application as normal, however, under Deployment Types and then Requirements, you can now add the Global Condition:
Once you have clicked the Add button you can Create your requirement by selecting the following:
Category: Custom

Condition: (the name of the Global Condition you have just created)
Rule Type: Value
Operator: Equals
Value: False

So, you should have a requirement that now looks like this:
This means that this software now has a requirement that the Powershell script that will run as part of the Global Condition must return a False value to allow the software to run.
You can now complete your application as normal and deploy to your users. You should now notice that if Outlook is left open, the software will not attempt to install and fail. If you close Outlook, it will run successfully.
If you have any questions and further requests into this type of configuration, please leave a comment and I’ll reply when I can.

You might also like...

Leave us a message...

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