143 votesstarted · AdminAdam Meltzer (ConfigMgr Product Team) (Software Engineer, Microsoft Endpoint Configuration Manager) responded
Changing status back to “Started” as there’s more work to do here. We plan to simplify adding requirements to DTs as well as complete the missing scenarios for detection methods in a future release. Stay tuned for more updates.
An error occurred while saving the commentAnonymous commented
I don't remember where I got the bones of this - but it works by getting the requirement off one deploymenttype and applying that object to the other deploymenttype. snip below assumes you've set a $SiteDrive variable already.
#Select an application and deploymenttype with a requirement you want to copy
$name1 = "James_Baseline_WorkstationOS"
$App1 = Get-CMApplication -Name $name1
$i = 0
$DeploymentTypeName = Get-CMDeploymentType -DeploymentTypeName $name1 -ApplicationName $name1
$App1XML = [Microsoft.ConfigurationManagement.ApplicationManagement.Serialization.SccmSerializer]::DeserializeFromString($app1.SDMPackageXML)
#Get the requirement itself
$OSRule = $App1XML.DeploymentTypes[$i].Requirements
$oAnnotation = $App1XML.DeploymentTypes[$i].Requirements.annotation
$oOSExpression = $App1XML.DeploymentTypes[$i].Requirements.Expression
$oSeverity = $App1XML.DeploymentTypes[$i].Requirements.severity
#Create a rule to be applied to other deploymenttypes
$newrule = new-object "Microsoft.SystemsManagementServer.DesiredConfigurationManagement.Rules.Rule" -ArgumentList (("Rule_" + [Guid]::NewGuid().ToString()), $oSeverity, $oAnnotation, $oOSExpression)
#Now apply all this on other Apps
#get applications - edit the filter for the app(s) you want to target
$filter1 = "*"
$Apps = Get-CMApplication -Name $filter1
foreach ($AppName in $apps)
$DTs = Get-CMDeploymentType -ApplicationName $($AppName.LocalizedDisplayName)
Foreach ($DT in $DTs)
#get only those that don't already have the requirement set'
if ($DT -notmatch $($OSRule.name))
#apply the rule created to the deploymenttype - creates the requirement
$DT | Set-CMDeploymentType -AddRequirement $newrule
Start-Sleep -Seconds 1