/// <summary> /// performs a specific run set /// </summary> /// <param name="server"> /// The WSUS Server /// </param> /// <param name="runSet"> /// A specific run set /// </param> /// <param name="isTest"> /// Whether we are in test mode /// </param> private static void DoRunSet(IUpdateServer server, RunSet runSet, bool isTest) { Console.WriteLine("Performing Run Set: " + runSet.Name); // get the target group rules Configuration.CheckIsValidRunSet(server, runSet); var alreadyProcessed = new List <IComputerTargetGroup>(); if (runSet.TargetGroups.ElementInformation.IsPresent) { Console.WriteLine("Target Groups specified in Run Set."); TargetGroupCollection targetGroups = runSet.TargetGroups; foreach (TargetGroup targetGroup in targetGroups) { DoRunSetTargetGroup(server, targetGroup, isTest, alreadyProcessed); } } else if (runSet.AllTargetGroups.ElementInformation.IsPresent) { AllTargetGroups allTargetGroups = runSet.AllTargetGroups; DoRunSetAllTargetGroups(server, allTargetGroups, isTest, alreadyProcessed); } else { throw new ConfigurationErrorsException( "Couldn't find a \"targetGroup\" or \"allTargetGroups\" element in the runset."); } }
/// <summary> /// /// </summary> static private void CheckIsValidAllTargetGroups( Microsoft.UpdateServices.Administration.IUpdateServer server, AllTargetGroups allTargetGroups, System.String runSetName ) { Rule allClassifications = allTargetGroups.AllClassifications; ClassificationCollection classifications = allTargetGroups.Classifications; CheckIsValidClassifications(server, allClassifications, classifications, runSetName, null); }
/// <summary> /// The do run set all target groups. /// </summary> /// <param name="server"> /// </param> /// <param name="allTargetGroups"> /// </param> /// <param name="isTest"> /// </param> /// <param name="alreadyProcessed"> /// List of target groups that have already been processed /// </param> private static void DoRunSetAllTargetGroups( IUpdateServer server, AllTargetGroups allTargetGroups, bool isTest, List <IComputerTargetGroup> alreadyProcessed) { Console.Out.WriteLine("Getting root target group: "); IComputerTargetGroup rootGroup = Server.GetRootTargetGroup(server); ClassificationCollection classifications = allTargetGroups.Classifications; if (classifications.Count > 0) { DoRunSetClassifications(server, rootGroup, classifications, isTest, alreadyProcessed); } else { DoRunSetAllClassifications(server, rootGroup, isTest, allTargetGroups.AllClassifications); } }
/// <summary> /// /// </summary> static public void CheckIsValidRunSet( Microsoft.UpdateServices.Administration.IUpdateServer server, RunSet runSet ) { TargetGroupCollection targetGroups = runSet.TargetGroups; AllTargetGroups allTargetGroups = runSet.AllTargetGroups; if ( targetGroups.Count == 0 && allTargetGroups.ElementInformation.IsPresent == false ) { throw new System.ArgumentException( "\"AllTargetGroups\" or \"TargetGroups\" missing from the runset \"" + runSet.Name + "\"." ); } if ( targetGroups.Count > 0 && allTargetGroups.ElementInformation.IsPresent ) { throw new System.ArgumentException( "\"AllTargetGroups\" and \"TargetGroups\" are both specified in runset \"" + runSet.Name + "\". You must specify one or the other." ); } if (targetGroups.Count > 0) { CheckIsValidTargetGroups(server, targetGroups, runSet.Name); } else { CheckIsValidAllTargetGroups(server, allTargetGroups, runSet.Name); } }
/// <summary> /// /// </summary> private static void CheckIsValidAllTargetGroups( Microsoft.UpdateServices.Administration.IUpdateServer server, AllTargetGroups allTargetGroups, System.String runSetName ) { Rule allClassifications = allTargetGroups.AllClassifications; ClassificationCollection classifications = allTargetGroups.Classifications; CheckIsValidClassifications(server, allClassifications, classifications, runSetName, null); }