Monday, March 18, 2013

CM 2012 Application Model - Custom Detection Methods

The new Application Model in CM 2012 includes detection methods. These methods must be met for an application to be labeled as "Installed". This same process prevents an application from being installed if the method is already met.

The default detection methods work great for standard applications. Every once in a while though, you may need to use a custom method. Custom methods are scripts that can be ran to determine if an application is installed. I use the term "installed" loosely, simply meaning that the objective of the application has been reached. You may have applications that change a setting, and do not install anything. These custom methods may be the only way to determine if that setting has been changed.

There are three scripting types that you can choose from - PowerShell, VBScript, and JScript. I do everything possible in PowerShell, so that will be the focus of this blog. You can reference this TechNet article for detail on what I am going to show: http://technet.microsoft.com/en-us/library/gg682174.aspx. I cannot link straight to the section, so expand "Step 4: Configure Detection Methods to Indicate the Presence of the Application" and "To use a custom script to determine the presence of a deployment type". This shows the chart that I will reference.

So as you can see with this chart, there are several combinations of exit codes and strings that can be used to indicate whether an application is installed. I use an exit code of zero and a STDOUT string of "The application is installed" to indicate that the application is already installed. STDOUT can be set to anything, as long as it is not blank. I use an exit code of zero and a STDOUT of empty to indicate that the application is NOT installed.

To test if an application is present, I simply do an IF statement that sets the correct exit code and string. Here is an example. This example is testing if the SCCM client cache is greater than 25600MB. If it is, the application is considered installed. If it is not, the application is considered not installed.

If (((Get-WmiObject -namespace root\ccm\SoftMgmtAgent -class CacheConfig).Size) -ge "25600") {
Write-Host "The application is installed"
Exit 0 }


If (((Get-WmiObject -namespace root\ccm\SoftMgmtAgent -class CacheConfig).Size) -lt "25600")  {
Exit 0 }


Disclaimer: I know that this can be done with an ELSE instead of two IF statements, but this method helps me to see what is going on clearer.

To write the STDOUT string, you simply need the Write-Host command, which the first part of the script is doing.

It is very important to set the exit code. As you can see in the chart, if the exit code is not set, the application detection state is set to "Unknown", meaning the CM doesn't know what to do with it. The application will neither install, or show up as installed.

Bottom line, you can use anything that can be scripted to detect if an application is present. At the end of the script, simply set the exit code to 0 and write the STDOUT string if the application is present, or leave it empty if the application is not present.

I hope this helps in your application deployments.

Wednesday, March 6, 2013

Applications have to download?


Background:
SCCM 2012 introduces a new method of doing software installs. There are now Packages, which is the legacy way of doing software, and Applications. Among other things, Applications give much better reporting and targeting features.

So I pose this as more of a question. It appears that Applications in SCCM 2012 have to download and install instead of there being an option to run them from the distribution points. Is anyone else ran across this yet? The only solid documentation on run types is one sentence in a reference book for SCCM 2012. It says that Run from DP is only available for Packages.

I am trying to turn our AutoCAD 2013 packages in applications. We provide 13 different programs from the AutoCAD suite, with each package being about 17GB. When setting up our client installation rules, we left the default client cache size at 5GB. If applications have to download before installation, then this cache size will have to be changed. I find it hard to believe that Microsoft would have removed the option to run from distribution points, but it appears that they have.

I have methods in place to change the cache size if needed, but I do not want to do this if I don't have too. I can use the right-click tools, or come up with a script to run prior to the application install, but I would much rather have the applications run from the DP's. AutoCAD isn't the only problem that I will have. We have several packages that are more than the 5GB default.

Will I see issues with this when trying to install these applications as part of a task sequence? All of our task sequences are set to run from distribution point.

Comments or suggestions? Leave a comment here or email me at sccmhied@gmail.com.