Microsoft Endpoint Configuration Manager Feedback

Suggestion box powered by UserVoice


My feedback

  1. 157 votes
    Sign in
    Sign in with: Facebook Google
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    10 comments  ·  Ideas » PowerShell  ·  Flag idea as inappropriate…  ·  Admin →
    An error occurred while saving the comment
    Anonymous 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.


    Set-Location $SiteDrive
    #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 $($
    #apply the rule created to the deploymenttype - creates the requirement
    $DT | Set-CMDeploymentType -AddRequirement $newrule
    Start-Sleep -Seconds 1
    Write-Host $AppName.LocalizedDisplayName



Feedback and Knowledge Base