How to add dependencies for an application in SCCM 2012 R2 using PowerShell 3.0

This topic contains 4 replies, has 3 voices, and was last updated by  SARANGARAJ D 2 years, 2 months ago.

  • Author
    Posts
  • #27428

    SARANGARAJ D
    Participant

    Hi All,

    I'm just a beginner for PowerShell and I'm quite interested in learning PowerShell scripting.
    I've been working on automation in SCCM 2012R2.
    I've created a basic PS script to create, distribute and deploy an application in SCCM 2012 R2. But I'm not able to figure out how to add dependencies in SCCM 2012 R2 using PS.
    Though I've seen lot of scripts in online and i can do copy paste the script, but i want to really understand the script and work on.

    So, can anyone help me with the script and explanation???

    Thanks in advance.

  • #27429

    Tim Pringle
    Participant

    Hi Sarangaraj,

    SCCM can be managed from PowerShell in multiple ways, some by hooking into a couple of the DLLs, and others solely via WMI.

    If you can paste the script, maybe we can try and help to explain it to you... 😉

  • #27431

    Graham Beer
    Participant

    Hi,

    I've found that the cmdlets that come with SCCM are pretty good and I've managed to automate quite a few things with them.

  • #27448

    SARANGARAJ D
    Participant

    Hi Tim,

    Thanks for your reply.
    Below is the script which I got from internet.
    If you prefer any other script that is also fine, but that requires explanation 🙂 

    sccm.Application application = GetApplicationFromName(txtSCCMApplicationName.Text);
    sccm.Application appToSupersede = GetApplicationFromName(cmbSuperseded.Items[cmbSuperseded.SelectedIndex] as string);

    sccm.DeploymentType dt = application.DeploymentTypes[0];
    sccm.DeploymentType ssdt = appToSupersede.DeploymentTypes[0];
    DeploymentTypeIntentExpression intentExpression = newDeploymentTypeIntentExpression(appToSupersede.Scope, appToSupersede.Name, (int)appToSupersede.Version, ssdt.Scope, ssdt.Name, (int)ssdt.Version,DeploymentTypeDesiredState.Prohibited, true);
    DeploymentTypeRule deploymentRule = new DeploymentTypeRule(NoncomplianceSeverity.None,null, intentExpression);
    dt.Supersedes.Add(deploymentRule);

    SaveApplication(application);

  • #27451

    SARANGARAJ D
    Participant

    Hi Graham,

    Thanks for your reply

    It would be great, If you share the cmdlets to add dependencies 🙂

You must be logged in to reply to this topic.