How to Import a New Management Pack
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);
}
}
}
' Creates a new Management Pack by using the specified
' identity elements.
Imports System
Imports Microsoft.EnterpriseManagement
Imports Microsoft.EnterpriseManagement.Common
Imports Microsoft.EnterpriseManagement.Configuration
Imports Microsoft.EnterpriseManagement.Configuration.IO
Imports Microsoft.EnterpriseManagement.Monitoring
Imports System.Text
Namespace SDKSamples
Class Program
Public Overloads Shared Function Main(ByVal args() As String) As Integer
Dim mg As ManagementGroup = New ManagementGroup("localhost")
' Define the version of the Management Pack.
Dim version As String = "1.0.0.0"
Dim initialVersion As Version = New Version(version)
' Create a Management Pack store to indicate one or more directories where
' referenced Management Packs are stored.
Dim mpStore As ManagementPackFileStore = New ManagementPackFileStore()
Dim directory As String = "C:\Program Files\System Center Management Packs\"
mpStore.AddDirectory(directory)
' Create the Management Pack.
Dim mpName As String = "SampleMP" ' full name of the management pack.
Dim friendlyName As String = "Test Management Pack 1"
Dim mp As ManagementPack = _
New ManagementPack(mpName, friendlyName, initialVersion, mpStore)
' Import the Management Pack.
mg.ImportManagementPack(mp)
End Function
End Class
End Namespace
See Also
Tasks
How to Display Management Pack Contents