How to move views in My Workspace into a Management Pack


 

Customers often use “My Workspace” to create customized views that they use on a regular basis.  However, one of the drawbacks on My Workspace is that these views are not available to any other users. 

Generally, we recommend customers use My Workspace to test and develop views, then simply re-create them in a Management Pack when they are happy with the results.  But what if you wanted to just forklift them from My Workspace, into a MP programmatically?

This isn’t simple – because of how these views are stored.  You can access these views in the database with the following query:

 

SELECT ss.UserSid, ss.SavedSearchName AS 'ViewDisplayName', vt.ViewTypeName, mpv.Name AS 'MPName', ss.ConfigurationXML FROM SavedSearch ss INNER JOIN ViewType vt ON ss.ViewTypeId = vt.ViewTypeId INNER JOIN ManagementPackView mpv on vt.ManagementPackId = mpv.Id WHERE ss.TargetManagedTypeId is not NULL

 

This will yield output like so:

 

image

 

From this, you can either manually copy and paste this data into a management pack, or you could event build an MP snippet to take this data as input from a CSV, based on the query output.  https://blogs.technet.microsoft.com/kevinholman/2014/01/21/how-to-use-snippets-in-vsae-to-write-lots-of-workflows-quickly/

 

Here is a simple MP example where you could manually copy and paste the My Workspace data into:

 

<?xml version="1.0" encoding="utf-8"?><ManagementPack ContentReadable="true" SchemaVersion="2.0" OriginalSchemaVersion="1.1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <Manifest> <Identity> <ID>Demo.Views</ID> <Version>1.0.0.0</Version> </Identity> <Name>Demo - Views</Name> <References> <Reference Alias="SC"> <ID>Microsoft.SystemCenter.Library</ID> <Version>7.0.8433.0</Version> <PublicKeyToken>31bf3856ad364e35</PublicKeyToken> </Reference> <Reference Alias="System"> <ID>System.Library</ID> <Version>7.5.8501.0</Version> <PublicKeyToken>31bf3856ad364e35</PublicKeyToken> </Reference> </References> </Manifest> <Presentation> <Views> <View ID="View.1" Accessibility="Public" Enabled="true" Target="System!System.Entity" TypeID="SC!Microsoft.SystemCenter.AlertViewType" Visible="true"> <!-- In the line above change the following: Change the View ID to something unique in this MP for each view you create Change the MP reference alias (SC!) to match a reference MP seen in MPName Change the ViewType example (Microsoft.SystemCenter.AlertViewType) from ViewTypeName --> <Category>Custom</Category> <!-- Insert your query data ConfigurationXML below this line --> <!-- Insert your query data ConfigurationXML above this line --> </View> </Views> <Folders> <Folder ID="Demo.Views.Root.Folder" Accessibility="Public" ParentFolder="SC!Microsoft.SystemCenter.Monitoring.ViewFolder.Root" /> </Folders> <FolderItems> <FolderItem ElementID="View.1" ID="ib42bd9704bf54df0a6c18c9f5c1614ca" Folder="Demo.Views.Root.Folder" /> </FolderItems> </Presentation> <LanguagePacks> <LanguagePack ID="ENU" IsDefault="false"> <DisplayStrings> <DisplayString ElementID="Demo.Views"> <Name>Demo - Views</Name> </DisplayString> <DisplayString ElementID="Demo.Views.Root.Folder"> <Name>Demo - Views</Name> </DisplayString> <DisplayString ElementID="View.1"> <Name>All Alerts</Name> </DisplayString> </DisplayStrings> </LanguagePack> </LanguagePacks> </ManagementPack>

As you can see, it is a lot of work, not something I’d want to do on a regular basis…. but if you had this as a requirement, it’s possible!  Smile


Comments (0)

Skip to main content