/// <summary> /// Using the priority 1 deployment types from two applications, create a supersedence relationship /// </summary> public static void AddSupersedence(string newApplicationName, string supersededApplicationName, bool uninstall, string server) { Application newApp = CMApplication.GetApplicationByName(newApplicationName, server); Application supersededApp = CMApplication.GetApplicationByName(supersededApplicationName, server); DeploymentType newAppDeploymentType = newApp.DeploymentTypes[0]; DeploymentType supersededAppDeploymentType = supersededApp.DeploymentTypes[0]; DeploymentTypeIntentExpression intentExpression = new DeploymentTypeIntentExpression(supersededApp.Scope, supersededApp.Name, (int)supersededApp.Version, supersededAppDeploymentType.Scope, supersededAppDeploymentType.Name, (int)supersededAppDeploymentType.Version, DeploymentTypeDesiredState.Prohibited, uninstall); DeploymentTypeRule deploymentRule = new DeploymentTypeRule(NoncomplianceSeverity.None, null, intentExpression); newAppDeploymentType.Supersedes.Add(deploymentRule); CMApplication.Save(newApp, server); }
private void btnSupersedeApplication_Click(object sender, EventArgs e) { ////retrieve app that was created sccm.Application application = GetApplicationFromName(txtSCCMApplicationName.Text); ////retrieve application that will be superseded sccm.Application appToSupersede = GetApplicationFromName(cmbSuperseded.Items[cmbSuperseded.SelectedIndex] as string); sccm.DeploymentType dt = application.DeploymentTypes[0]; sccm.DeploymentType ssdt = appToSupersede.DeploymentTypes[0]; //// Define an intent expression to describe the realtionship between the applications DeploymentTypeIntentExpression intentExpression = new DeploymentTypeIntentExpression(appToSupersede.Scope, appToSupersede.Name, (int)appToSupersede.Version, ssdt.Scope, ssdt.Name, (int)ssdt.Version, DeploymentTypeDesiredState.Prohibited, true); //// Define a deployment type rule to contain the expression DeploymentTypeRule deploymentRule = new DeploymentTypeRule(NoncomplianceSeverity.None, null, intentExpression); //// Add to Supersedes collection. dt.Supersedes.Add(deploymentRule); SaveApplication(application); }
/// <summary> /// Using the priority 1 deployment types from two applications, create a supersedence relationship /// </summary> public static void AddSupersedence(string newApplicationName, string supersededApplicationName, bool uninstall, string server) { Application newApp = CMApplication.GetApplicationByName(newApplicationName, server); Application supersededApp = CMApplication.GetApplicationByName(supersededApplicationName, server); DeploymentType newAppDeploymentType = newApp.DeploymentTypes[0]; DeploymentType supersededAppDeploymentType = supersededApp.DeploymentTypes[0]; DeploymentTypeIntentExpression intentExpression = new DeploymentTypeIntentExpression(supersededApp.Scope, supersededApp.Name, (int)supersededApp.Version, supersededAppDeploymentType.Scope, supersededAppDeploymentType.Name, (int)supersededAppDeploymentType.Version, DeploymentTypeDesiredState.Prohibited, uninstall); DeploymentTypeRule deploymentRule = new DeploymentTypeRule(NoncomplianceSeverity.None, null, intentExpression); newAppDeploymentType.Supersedes.Add(deploymentRule); CMApplication.Save(newApp, server); }