How to Import a New Management Pack

Applies To: System Center 2012 - Operations Manager

[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

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 about 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.ManagementPacks.ImportManagementPack(mp);           
        }
    }
}

See Also

Tasks

How to Display Management Pack Contents

Other Resources

Automating Management Pack Development