Hacking Management Pack XML Like a Pro

Hacking Management Pack XML Like a Pro

  • Comments 7
  • Likes

Sometimes when you need to make some changes nothing beats a good ol’ text editor.  There are cases right now where the only way to change something in Service Manager is by editing the management pack XML directly.  There are also cases where it is just faster to edit the XML directly.  To that end… here is a primer on how to edit MPs directly.  (Also, this is a great way to reverse engineer the product but shhh… don’t tell anybody I told you that. ;-))

First, you need to get the management pack out of the database.  For unsealed MPs, this is pretty easy to do. 

1.       In the Service Manager console, go to the Administration workspace.

2.       Click on the Management Packs view.

3.       Select the unsealed management pack you want to export.

4.       Click Export in the task pane. 

5.       You’ll be prompted for the location you want to save the .xml file to. 

For sealed MPs this is a little trickier.  Before we go here, it’s important to keep in mind that sealed MPs usually have dependencies on them and they are signed by Microsoft or a partner so you won’t be able to modify them.  That’s why we discourage people from exporting them.  But if you are just interested in how Service Manager ticks, you can export them using a tool called mpexport.exe. 

1.       To export a sealed MP you need to get the GUID of that MP from the database.  Open SQL Management Studio and select the SMCMDB (to be renamed to ‘ServiceManager’ starting in Beta 2) database.  Run a query like this:

 

SELECT ManagementPackId, MPName, MPFriendlyName FROM ManagementPack

 

 

2.       Now copy the GUID of the MP that you want to export from the result set to your clipboard. 

3.       Open a command prompt (Start -> Run or Windows Key + R, type ‘cmd’, hit enter or from Start menu).

4.       Type cd <location of your Service Manager installation directory> and hit enter

For example the default installation directory for Service Manager:

cd C:\Program Files\Microsoft System Center\Service Manager 2010

5.       Type mpexport <paste the GUID here>

For example to export the System.Knowledge.Libary MP from above:

mpexport DCAF6D66-4CB0-1DDA-FB9A-0B0EC49784E4

 

6.       This will save the MP .xml file to the same location as mpexport.exe

 

 

Update: Starting with Service Manager Beta 2 builds (build # 5037+) the mpexport.exe and mpimport.exe utilities will be removed and replaced by PowerShell cmdlets.  This should make it much easier to export MPs since you don't need to mess around looking for GUIDs in the database.  Here is an example:

PS> Get-SCSMManagementPack Incident | Export-SCSMManagementPack -Directory c:\temp 

Or, if you are feel like being a PowerShell hotshot you can follow Jim’s approach to exporting MPs en masse.

Now that you have your MP xml file, open it in your favorite text editor. Since these are XML files I suggest opening them in a text editor designed for editing XML files such as Visual Studio , XML Spy, Notepad++.

At first glance looking at an MP in its raw XML form can be pretty daunting especially if it is one of the larger MPs that ship out of the box.  In a lot of cases, especially if something has been generated from the UI, the ID of some of the MP elements may not be distinguishable.   For that reason I recommend starting by looking in the <LanguagePack> section of an MP.  Here you can see the localized display strings for the MP elements in the MP.  For example here is the DisplayString for the All Tier 3 Open Incidents view (click to view full size): 

 Now – to find the element you are looking for in the MP you can search for ‘ID=”<Element ID you are interested in>”’.  For example search for:

ID=”System.WorkItem.Incident.Queue.Tier3.View”

This will lead you to the corresponding MP element like this:

You can also see other places where the MP element with that ID is being used by searching for just the ID or by searching for phrases like “Target=<ElementID you are interested in>” or “MPElement=<ElementID you are interested in>” – for example:

Target=”System.WorkItem.Incident.Queue.Tier3.View”

MPElement=”System.WorkItem.Incident.Queue.Tier3.View”

That will show you things like this (click to view full size):

Which indicate that the view is part of a category.

Or this (click to view full size):

Which indicates that the view is contained by this folder.

Or this (click to view full size):

Which indicates which icon corresponds to that view.

One thing to keep in mind is that  you cannot delete an MP element like the <View> above without making sure that there are no Target or MPElement references in other MP elements that point to the ID of that MP element (System.WorkItem.Incident.Queue.Tier3.View in this case).  For example, in order to delete this view here, I would first need to delete the corresponding <FolderItem>, <ImageReference>, <Category>, and even the <DisplayString> that we started from.

Editing MPs by hand is not for the faint of heart, but it is a great way to debug problems, make bulk edits, reverse engineer things, do things which cannot be done via the UI, or revert changes that cannot be undone via the UI.

Sometimes it can be a bit of trial and error when it comes to editing MPs by hand, but to help you along (as long as you don’t mind a little reading) I recommend the following resources:

·         Operations Manager 2007 MP Authoring Guide (remember Operations Manager and Service Manager are built on essentially the same platform): http://download.microsoft.com/download/7/4/d/74deff5e-449f-4a6b-91dd-ffbc117869a2/OM2007_AuthGuide.doc

·         http://www.AuthorMPs.com

·         The Service Manager authoring guide available on http://connect.microsoft.com

 Happy MP XML Hacking!

Also, see some of Jim Truher's posts on this blog for other examples of working with MPs via PowerShell:

http://blogs.technet.com/servicemanager/archive/2009/02/06/service-manager-and-powershell.aspx

http://blogs.technet.com/servicemanager/archive/2009/03/10/more-with-management-packs.aspx

 

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • PingBack from http://rapasasolutions01.com/22/system-center-service-manager-hacking-management-pack-xml-like-a-pro/

  • My <a href="www.liquid-technologies.com/XML-Editor.aspx"> xml editor  </a> does a lot of this for me, I dont even have to code much of it which makes life a lot easier.  

  •  Hey people, with last version of SMLets, export command change "-Directory" parameter with the new "-TargetDirectory"...

    Regards,

    VGC

  • Hello, i exported my mp, edited in xml Editor, sealed it back again the Authoring tool . Now the question is : How do you reimport it back to SCSM ?when i import the mp i have the following error:

    The management pack import failed.

    Errors (1):

    Database error. {0} failed with exception:

    {1}

    : Database error. MPInfra_p_ManagementPackInstall failed with exception:

    Database error. MPInfra_p_ManagementPackInstall failed with exception:

    ManagementPack cannot be imported because it contains a Managed Type with the same name as an existing type: System.WorkItemGroup

  • @SCSM Dev:

    Which MP did you export?

  • I am new to SCSM. I was able to install this successfully. I had few issues in the beginning related to domain setup and then disk size(space constraints and I had compressed the disk), changed the domain after SCSM installation because of that it took 2 days for me to fix all these issues and install web portal successfully. So far it seems very complex solution in case of issues(if no issues then straight forward of course). Now I am stuck with development/customization thing. Authoring tool seems to be very basic and does not have much functionalities to change the GUI. I want to add a related list or table on incident form(on a custom tab) to show data from a custom form. I am not able to choose that from authoring tool. Similarly we need to create SRs with custom interface for users which has different table(Listbox, grid view) to show information to users.

    I am confused and stuck where to go from here. How to use visual studio or expression to add those tables in UI of existing forms or new forms. Documentation in this area is very very limited and overall experience is kind of disappointing till now. We are evaluating this tool in comparison to existing BMC Remedy(Which seems miles ahead in terms of ease of use, documentation, ease of customization) and I need to prepare a report in 2 weeks.

    Any suggestion, help in the area of customization will be really helpful.

  • Hello,

    I am having the same issue as SCSM Dev, except I didn't export an existing management pack. I created a custom form using the Visual Studio Authoring extensions and I am trying to bundle it into a .mpb file so that I can use my custom form in SCSM. I want this to replace my default incident form. In Visual Studio I created a new project from existing management pack. Now, I was thinking this meant inheriting from the existing management pack, so I chose the default incident management pack to "inherit" from if I am using it properly. I added my .dll file with my custom form as a reference to my project and set "Package To Bundle" as true. Then, after building and getting my .mpb file, I try to import it into SCSM. Everytime I do this I get

    "
    The management pack import failed.
    Errors (1):
    Database error. {0} failed with exception:
    {1}
    : Database error. MPInfra_p_ManagementPackInstall failed with exception:
    Database error. MPInfra_p_ManagementPackInstall failed with exception:
    ManagementPack cannot be imported because it contains a Managed Type with the same name as an existing type: System.WorkItem.Incident
    "

    Do you know what I am doing wrong? Thank you.