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.
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 "18.104.22.168" # 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.