/// <summary> /// Using the static ManagementGroupConnector this method pulls the monitoring state /// for the Community Pack Update Monitor /// </summary> /// <returns>The <see cref="MonitoringState"/> object that represents the Community Pack Update Monitor.</returns> private MonitoringState GetPackUpdateMonitorState() { // Filter to the Root Management Server Emulator role, there is only one instance of this class so the criteria can be simple. ManagementPackClass rootManagementServerClass = ManagementGroupConnector.CurrentManagementGroup.EntityTypes.GetClass(Guid.Parse("1a9387f0-6fe5-5527-a2cb-73f2f6be6bc7")); MonitoringObjectGenericCriteria monitoringObjectCriteria = new MonitoringObjectGenericCriteria("FullName like 'Microsoft.SystemCenter%'"); IObjectReader <MonitoringObject> monitoringObjects = ManagementGroupConnector.CurrentManagementGroup.EntityObjects.GetObjectReader <MonitoringObject>(monitoringObjectCriteria, rootManagementServerClass, ObjectQueryOptions.Default); MonitoringObject rootManagementServerInstance = monitoringObjects.GetData(0); // For the instance of the Root Management Server Emulator we need to cross that with the Monitor to get the exact monitoring state item ManagementPackMonitorCriteria monitorsCriteria = new ManagementPackMonitorCriteria("Name = 'Community.ManagementPackCatalog.PackStatusMonitor'"); ManagementPackMonitor updateManagementPackMonitor = ManagementGroupConnector.CurrentManagementGroup.Monitoring.GetMonitors(monitorsCriteria)[0]; // Creating a list of one item we pull the current monitoring state of the Update Status monitor var monitorList = new List <ManagementPackMonitor>(); monitorList.Add(updateManagementPackMonitor); MonitoringState packStatus = rootManagementServerInstance.GetMonitoringStates((IEnumerable <ManagementPackMonitor>)monitorList)[0]; return(packStatus); }