Export (0) Print
Expand All

How to Import a New Management Pack

System Center

Updated: May 22, 2009

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

You can use the Operations Manager class libraries to create and import a new Management Pack.

Example

This example demonstrates how to import a new Management Pack for use in a Management Group. For information on creating Management Packs, see How to Create a Management Pack.

/// <summary>
/// Creates a new Management Pack by using the specified
///  identity elements.
/// </summary>
using System;
using System.Collections.Generic;
using Microsoft.EnterpriseManagement;
using Microsoft.EnterpriseManagement.Configuration;
using Microsoft.EnterpriseManagement.Configuration.IO;
using System.Text;

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

            // Define the version of the Management Pack.
            string version = "1.0.0.0";
            Version initialVersion = new Version(version);

            // Create a Management Pack store to indicate one or more directories where
            // referenced Management Packs are stored.
            ManagementPackFileStore mpStore = new ManagementPackFileStore();
            string directory = @"C:\Program Files\System Center Management Packs\";
            mpStore.AddDirectory(directory);

            // Create the Management Pack.
            string mpName = "SampleMP";  // full name of the management pack.
            string friendlyName = "Test Management Pack 1";
            ManagementPack mp = 
                new ManagementPack(mpName, friendlyName, initialVersion, mpStore);

            // Import the Management Pack.
            mg.ImportManagementPack(mp);           
        }
    }
}

See Also

Show:
© 2014 Microsoft