PowerShell: How to add enhanced detection methods to deployment types (1705 TP)

Update: These cmdlets did not make it into the 1704 TP, but they will be in the 1705 TP. This posting has been updated to correct this.

In the upcoming 1705 technical preview of Configuration Manager, we have finally added the much-requested ability to add enhanced detection method clauses to deployment types PowerShell. This posting will discuss the basic concepts of how this will work, along with what is and is not supported at this time.

What is supported

For 1704 technical preview the following functionality can now be done through PowerShell:

  • Add and remove file, folder, registry key, registry key value, and MSI version detection clauses to MSI and script deployment types.
  • Add and remove bundle and package detection clauses to Mac deployment types.

What is not supported

These features are planned to be added in a future release:

  • Modify detection clauses in place
  • Group/ungroup detection clauses

How it works

A detection clause object is created with one of the new New-CMDetectionClause<type> cmdlets, and then added to a new or existing deployment type using the -AddDetectionClause parameter. One or more detection clauses can be added at a time.

Example

Two detection clauses are created, one for an existing installer matching a specific value, and another for a directory to exist on the C drive. These clauses are then added to a new deployment type.

 
$clause1 = New-CMDetectionClauseWindowsInstaller -ProductCode $guid [Value -ExpressionOperator IsEquals -ExpectedValue "1.1.1.1" # Do a version check
$clause2 = New-CMDetectionClauseDirectory -DirectoryName "mymsi" -Path "C:\" -Existence # c:\mymsi should exist
$app | Add-CMMsiDeploymentType -ContentLocation "\\myserver\mypath\mymsi.msi" -Force -AddDetectionClause ($clause1, $clause2)

What cmdlets are included

These cmdlets have been created in 1704 to enable DCM rule and setting support:

  • New-CMDetectionClauseDirectory (MSI, Script)
  • New-CMDetectionClauseFile (MSI, Script)
  • New-CMDetectionClauseMacBundle (Mac)
  • New-CMDetectionClauseMacPackage (Mac)
  • New-CMDetectionClauseRegistryKey (MSI, Script)
  • New-CMDetectionClauseRegistryKeyValue (MSI, Script)
  • New-CMDetectionClauseWindowsInstaller (MSI, Script)

Note: Add/Set-CMMsiDeploymentType, Add/Set-CMScriptDeploymentType, and Add/Set-CMMacDeploymentType now have new -AddDetectionClause and -RemoveDetectionClauseparameters to facilitate adding and removing enhanced detection methods.

Comments

  • Anonymous
    April 21, 2017
    This is great news! Are we getting a new version of the SCCM cmdlets download? Will the module be included in the console installation? Will we be able to load it via the PowerShell gallery?
    • Anonymous
      June 27, 2017
      The updated modules will come with the updated console install. We're no longer doing standalone releases now that we can take advantage of the Current Branch release cadence.
  • Anonymous
    April 26, 2017
    Really looking forward to these being extended further as alluded to in this post. I have a need for this functionality in our Production Environment where we can create detailed Application Model Objects with enhanced detection methods, as well as dependencies programmatically with PowerShell.