How to Configure Management Group Properties

Applies To: Operations Manager 2007 R2, Operations Manager 2007 SP1, System Center Operations Manager 2007

The Operations Manager class libraries allow you to query and change many of the default Management Group settings.

Example

The following example demonstrates how to display the default heartbeat interval for all agent-managed computers in the Management Group. The example then changes the default interval to a new value.

/// <summary>
/// Displays the current default agent heartbeat interval,
/// and then changes the interval to 50 seconds.
/// </summary>
using System;
using System.Collections.Generic;
using Microsoft.EnterpriseManagement;
using Microsoft.EnterpriseManagement.Administration;
using System.Text;

namespace SDKSamples
{
    class Program
    {
        static void Main(string[] args)
        {
            ManagementGroup mg = new ManagementGroup("localhost");

            Console.WriteLine("Configuring Management Group properties...");
            
            ManagementGroupAdministration mga = mg.GetAdministration();
                        
            Console.WriteLine("The heartbeat interval is currently: "
+ mga.Settings.GetDefaultValue(Settings.Agent.Heartbeats.Interval));

            mga.Settings.SetDefaultValue<int>(Settings.Agent.Heartbeats.Interval,
                50);
            
            // need to call ApplyChanges to save the changes.
            //mga.Settings.ApplyChanges();

            Console.WriteLine("Agent heartbeat interval has now been set to: " +
                mga.Settings.GetDefaultValue(Settings.Agent.Heartbeats.Interval));            
        }
    }
}
' Displays the current default agent heartbeat interval,
' and then changes the interval to 50 seconds.
Imports System
Imports System.Collections.Generic
Imports Microsoft.EnterpriseManagement
Imports Microsoft.EnterpriseManagement.Administration
Imports System.Text

Namespace SDKSamples
    Class Program

        Public Overloads Shared Function Main(ByVal args() As String) As Integer
            Dim mg As New ManagementGroup("localhost")

            Console.WriteLine("Configuring Management Group properties...")

            Dim mga As ManagementGroupAdministration = mg.GetAdministration()

            Console.WriteLine("The heartbeat interval is currently: " & _
                mga.Settings.GetDefaultValue(Settings.Agent.Heartbeats.Interval).ToString())

            mga.Settings.SetDefaultValue(Of Integer)(Settings.Agent.Heartbeats.Interval, 50)
 
            ' need to call ApplyChanges to save the changes.
            'mga.Settings.ApplyChanges();

            Console.WriteLine("Agent heartbeat interval has now been set to: " & _
                mga.Settings.GetDefaultValue(Settings.Agent.Heartbeats.Interval).ToString())
        End Function 'Main
    End Class 'Program
End Namespace 'SDKSamples

See Also

Tasks

How to Display Management Pack Contents

Other Resources

Automating Operations Manager Administration