Custom Global Condition for Windows Features in MECM

It’s time for another back to the basics on Application building in MECM. You’re getting ready to create an Application in MECM. Said Application requires that a specific Windows Feature is enabled. I know I could use PowerShell App Deployment Toolkit or even a small custom PowerShell script to handle enabling the feature and running the install, but in this case I don’t want the Application to install if a particular Windows Feature is not enabled. To do this, I’m going to create a Custom Global Condition to detect if the Windows Feature in question is enabled.

Open your MECM console and go to \Software Library\Overview\Application Management\Global Conditions. Click on Create Global Condition on the ribbon. Give your Global Condition a name that makes sense for your environment. Put in a quick description of what it checks for. Device type is Windows and Condition type is Setting. Setting type is Script and Data type is String. Click the Add Script button.


For the Script language you’ll pick Windows Powershell. Paste in this script and click OK. Click OK one more time and you have created your Global Condition.

For the script I’m using for this demo, we’re looking to see if MSMQ-Triggers is enabled. You can check for any Windows Feature by swapping out ‘MSMQ-Triggers’ for the exact name of the Windows Feature you want. To lookup Windows Features in a graphically pleasant way, use the command Get-WindowsOptionalFeature -Online | OGV to dump out all the Windows Features to grid view.

# Set variables

$Feature = Get-WindowsOptionalFeature -Online | where -Property FeatureName -EQ 'MSMQ-Triggers'

 # Detect if feature is enabled

if ($Feature.State -eq 'Enabled')

{

    $Detect = "Enabled"

}

else

{

    $Detect = "NotEnabled"

} 

$Detect

Now it’s on to adding this Global Condition to your Application. Build your Application in MECM to your org’s standards, and then go to the properties for the Deployment Type. Go to the Requirements tab and click Add. Category is Custom, Condition is the name of the one you just created, Rule Type is Value, Operator is Equals, and Value is Enabled. Click OK to save the Requirement and OK to leave the Deployment Type properties.


Now you’re off to the races. Try to deploy your application on a computer where you know the Windows Feature is enabled and make sure it works. Then try to deploy your application on a computer where you know the Windows Feature is not enabled and make sure it doesn’t work. When it doesn’t work, you’ll see a status of “Requirements Not Meet” in the monitoring pane and on the local Software Center you’ll see a message that says the software isn’t applicable. Keep Calm & Global Condition On.

Comments

  1. Of course you would have a blog! Why am I just finding this out now? :)

    ReplyDelete

Post a Comment

Popular posts from this blog

CMPivot to check Services and start them (with a little help)

Run Scripts with Parameters in MEMCM (R.I.P. SCCM)

SCCM CMPivot and Run Scripts