Monday, May 13, 2013

Let’s Hack Some XML For Report Export To Another SCOM MG & Data Warehouse

With SCOM 2007 R2 and later a new feature to save Reports is introduced: Saving self created Reports in SCOM to a Management Pack (MP).

Even though this feature works great it has ONE huge drawback: this MP can’t be exported and imported into another SCOM Management Group (MG) which runs another Data Warehouse database. Microsoft is pretty clear about it in it’s online TechNet documentation for SCOM 2007 R2 and OM12 SP1:

Management packs can be exported and imported into other management groups and the reports will work only when these management groups share the same data warehouse.

Yes, the MP itself containing those Reports can easily be exported from one MG and imported into another MP running a whole different Data Warehouse. But when those Reports are run into the other MG (where the MP is imported) this error is thrown: Object reference not set to an instance of an object:

But with some quick editing the XML of this MP it can be exported to another SCOM MG using ANOTHER Data Warehouse database. Afterwards the Reports contained in that MP will still need some additional attention (selection of the correct Groups/Objects where the Reports are targeted against) but at least you don’t need to rebuild those Reports all over again, saving you a lot of time and hassle.

The steps involved
These are steps required to make it work:

  1. Create the Reports as required and save them to a single dedicated unsealed MP;
  2. When all the Reports are made export the MP;
  3. Open the related XML-file of the MP in a good editor like Notepad ++;
  4. Search for the entry <Parameter Name="ManagementGroupId">, like this:
    The GUID defined between <Value> and </Value> has to be replaced by the ManagementGroupId of the MG where this MP will be imported;
  5. Run the PS extensions on a MS of the MG where the MP exported in Step 2 will be imported and run this PS command: Get-SCOMManagementGroup | ft Id. Output will be like this:
    Copy this GUID;
  6. Replace all the GUIDs for the ManagementGroupId as stated in Step 4 with the GUID found in Step 5;
  7. Save the modifications to the XML file;
  8. Export this XML file into the new MG and presto, the Reports will run now (*).

(*: When Groups are used, the targeting of that Group will most likely go wrong. Simply select the correct Group and all other predefined parameter selections will be just fine. Now the Report will run successfully.)

No comments: