• MP Authoring Helper

    This week I’m having an internal MP Authoring Workshop from Brian Wren and I learned that it’s sometimes handy to have information available that’s not available when having the MP Authoring tool open. You can not switch to the Service Model when you have an other windows open.

    That’s why I created a PowerShell script that let’s you easily have a look at all the Classes, Discoveries, Relationships and Modules you already created in your Management Pack (if you have saved it).

    image

    image

    image

    image

    Just copy the script and save it to “MPAuthoringHelper_v1.003.ps1”

    ###############################################################################
    # Getting Classes from MP XML file and exporting it to csv for use in the
    # MP Authoring tool
    # Authors: Stefan Stranger
    # v1.001 - 27/01/2010 - sstranger - initial sstranger's release
    # v1.002 - 11/03/2010 - sstranger - added GetRelationshipTypes Function and changed GetClasTypes Function
    #                               - added GetDiscoveries Function
    # v1.003 - 11/03/2010 - sstranger - added GetModules Function
    ###############################################################################
    param ([string]$Path = $(read-host "Please enter MP XML path and file name"))

    #Globals
    $global:XmlMPFileDocument = new-object System.Xml.XmlDocument

    # Get MP XML file.
    # Make sure you saved your MP file to XML regularly.
    $XmlMPFileDocument.Load($Path)

    ##############################################################################################
    #Function GetClassTypes
    #
    #Get Class Types from MP XML file
    #############################################################################################
    Function GetClassTypes
    {
         $MyClassTypes = $XmlMPFileDocument.ManagementPack.TypeDefinitions.EntityTypes.ClassTypes.ClassType
        $MyClassTypes | select @{n='Class Name';e='ID'},@{n='Base Class';e='Base'}, Abstract, Singleton
    }

    ##############################################################################################
    #Function GetRelationshipTypes
    #
    #Get RelationShip Types from MP XML file
    #############################################################################################
    Function GetRelationshipTypes
    {
        $myRelationshipTypes = $XmlMPFileDocument.ManagementPack.TypeDefinitions.EntityTypes.RelationshipTypes.RelationshipType
        $myRelationshipTypes | select @{n='Name';e='ID'},@{n='Base Class';e='Base'}, Abstract, Source, Target
    }

    ##############################################################################################
    #Function GetDiscoveries
    #
    #Get Discoveries from MP XML file
    #############################################################################################
    Function GetDiscoveries
    {
         $myDiscoveries = @()
        foreach ($Discovery in $XmlMPFileDocument.ManagementPack.Monitoring.Discoveries.Discovery)
        {
            $obj = new-object System.Management.Automation.PSObject
            $obj = $obj | add-member -membertype NoteProperty -name "Name" -value $Discovery.ID -passthru
            $obj = $obj | add-member -membertype NoteProperty -name "Target" -value $Discovery.Target -passthru
            $obj = $obj | add-member -membertype NoteProperty -name "Discovery Class" -value $Discovery.DiscoveryTypes.DiscoveryClass.TypeID -passthru
            $obj = $obj | add-member -membertype NoteProperty -name "DS TypeID" -value $Discovery.DataSource.TypeID -passthru
            $myDiscoveries = $myDiscoveries + $obj
        }
        $myDiscoveries
    }

    ##############################################################################################
    #Function GetModules
    #
    #Get Modules from MP XML file
    #############################################################################################
    Function GetModules
    {
        $myModules = @()
        if ($XmlMPFileDocument.ManagementPack.TypeDefinitions.ModuleTypes.ProbeActionModuleType)
        {
            foreach ($ProbeModule in $XmlMPFileDocument.ManagementPack.TypeDefinitions.ModuleTypes.ProbeActionModuleType)
            {
                $obj = new-object System.Management.Automation.PSObject
                $obj = $obj | add-member -membertype NoteProperty -name "Module Type" -value "Probe" -passthru
                $obj = $obj | add-member -membertype NoteProperty -name "Name" -value $ProbeModule.ID -passthru
                $obj = $obj | add-member -membertype NoteProperty -name "Type ID" -value $ProbeModule.ModuleImplementation.Composite.MemberModules.ProbeAction.TypeID -passthru
                $myModules = $myModules + $obj
            }
        }
        if ($XmlMPFileDocument.ManagementPack.TypeDefinitions.ModuleTypes.DataSourceModuleType)
        {
            foreach ($DSModule in $XmlMPFileDocument.ManagementPack.TypeDefinitions.ModuleTypes.DataSourceModuleType)
            {
                $obj = new-object System.Management.Automation.PSObject
                $obj = $obj | add-member -membertype NoteProperty -name "Module Type" -value "Data Source" -passthru
                $obj = $obj | add-member -membertype NoteProperty -name "Name" -value $DSModule.ID -passthru
                $obj = $obj | add-member -membertype NoteProperty -name "Type ID" -value $DSModule.ModuleImplementation.Composite.MemberModules.DataSource.TypeID -passthru
                $myModules = $myModules + $obj
            }
        }
        if ($XmlMPFileDocument.ManagementPack.TypeDefinitions.ModuleTypes.WriteActionModuleType)
        {   
            foreach ($WAModule in $XmlMPFileDocument.ManagementPack.TypeDefinitions.ModuleTypes.WriteActionModuleType)
            {
                $obj = new-object System.Management.Automation.PSObject
                $obj = $obj | add-member -membertype NoteProperty -name "Module Type" -value "Write Action" -passthru
                $obj = $obj | add-member -membertype NoteProperty -name "Name" -value $WAModule.ID -passthru
                $obj = $obj | add-member -membertype NoteProperty -name "Type ID" -value $WAModule.ModuleImplementation.Composite.MemberModules.WriteAction.TypeID -passthru
                $myModules = $myModules + $obj
            }
        }
        if ($XmlMPFileDocument.ManagementPack.TypeDefinitions.ModuleTypes.ConditionDetectionModuleType)
        {   
            foreach ($ConditionModule in $XmlMPFileDocument.ManagementPack.TypeDefinitions.ModuleTypes.ConditionDetectionModuleType)
            {
                $obj = new-object System.Management.Automation.PSObject
                $obj = $obj | add-member -membertype NoteProperty -name "Module Type" -value "Condition Dectection" -passthru
                $obj = $obj | add-member -membertype NoteProperty -name "Name" -value $ConditionModule.ID -passthru
                $obj = $obj | add-member -membertype NoteProperty -name "Type ID" -value "See XML for more info" -passthru
                $myModules = $myModules + $obj
            }
        }
        $myModules
    }

    #Call Functions
    GetClassTypes | Out-GridView
    GetRelationshipTypes | Out-GridView
    GetDiscoveries | Out-GridView
    GetModules | Out-GridView

     

     

     

    It only needs one parameter and that’s the path and filename of the MP xml file you are creating. Remember to save your MP xml file regularly.

    image

    Have fun creating new MP’s!

  • Anybody wants to test my OpsMgr MP Authoring PowerGUI PowerPack?

    I just created my first PowerGUI PowerPack which you can use together with the MP Authoring Console. Just like I blogged previously in my MP Authoring Helper PowerShell script here.

    Here a teaser screenshot of the PowerGUI PowerPack.

    image

     

    It’s just a first version I created and I would like to have it tested a little more before posting it on the PowerGUI PowerPack library.

    So if anybody is creating MP’s using the MP Authoring Console and wants to try to use the MP Authoring PowerPack within PowerGUI to help creating MP’s let me know via Twitter via a DM or use the contact form on my weblog and I’ll email my PowerPack for testing.

  • SCOM Wiki Page on TechNet

    image

    Did you all know there TechNet is now in a Wiki Beta?

    What is TechNet Wiki Beta?

    The TechNet Wiki is a library of information about Microsoft technologies written by the community for the community. Whether you write code, manage servers, keep mission-critical sites up and running, or just enjoy digging into details, we think you will be at home in the TechNet Wiki.

    • This is a community site. For official documentation, see MSDN Library, TechNet Library or contact Microsoft Support.
    • The Wiki is focused on Microsoft technologies. The community will edit or remove topics that get too far off track.
    • We are inspired by Wikipedia.
    • Anyone who joins can participate and contribute content.

    For more information including how you can participate see http://social.technet.microsoft.com/wiki/

    But the cool thing is that there is also a SCOM Wiki page on TechNet. Go check it out and add content!

  • Connect and collaborate with other partners and Microsoft

    Source: Internal

    A couple of weeks ago I received some information about the new Microsoft Partner Network Community which is designed to facilitate real-time networking opportunities between people selling or building Microsoft solutions, Microsoft partners and Microsoft.

    And maybe this is also interesting for you.

    The community offers a number of ways for you to engage with your peers and Microsoft globally or directly within your region. You can:

    1. See what’s happening in your local community and region, attend partner events and engage in social media with people in your community.
    2. Get involved in Microsoft communities focused on student talent for hire, public policy affecting the technology industry, technology training and education and much more.
    3. Join the conversation with Microsoft and other partners through online social media like twitter, facebook and Microsoft and partner blogs.
    4. Keep up to date with the latest partner relevant news, webcasts and videos, and find product specific information and training within the broader Microsoft partner network.

    I’d like to direct you to a few partner network community resources that may be of interest to you and help you start the conversation with other partners and Microsoft.

    Take a sneak peek at what is being planned for the 2010 Worldwide Partner Conference

    Have fun connecting!

  • Reblog: QuickTricks – Select/unselect all in Reports

    Source: System Center Central 

    I just found this QuickTrick on System Center Central and I could not believe I didn’t know this trick…

    If you want to Select All or Unselect all in some of the Report Parameters boxes you can just right-click and there it is.

    Let’s take a look at the Overrides Report in my Demo environment.

    image

    Right-Click on the Management Pack Parameter Window.

    image

    image

    Great QuickTrick IMO.

    Thank you System Center Central!

  • Basic Troubleshooting Discovery Script (follow up on Kevin’s Post)

    This week I’m having a MP Authoring Workshop from Brian Wren in the UK and one of the modules of this workshop is Discovery.

    And to my surprise Kevin Holman published a blog post on Basic troubleshooting of discovery script yesterday. It’s a good start but I’ve some more help on troubleshooting a Discovery script.

    Here are mine (with some help of Brian):

    1. Verify that MP has been committed on agent
    2. Check agent for eventlog errors
    3. Check management server for errors
    4. Verify that discovery is running
    5. Enable debug events in script
    6. Debug script on agent

     

    Step 1. Verify that MP has been committed on agent.
    How?
    There are several ways. One of them is looking in the OpsMgr eventlog for EventId 1201.

    Step 2. Check for agent errors.
    How?
    Check for OpsMgr EventId’s like 31876 or 21405 or other Health Service Module source errors.

    Step 3. Check for management server errors
    How?
    Check for OpsMgr EventId’s 10801

    Step 4. Verify that discovery is running

    How?
    You can look for your discovery script in the C:\Program Files\System Center Operations Manager 2007\Health Service State\ subdirectories with the next command:
    dir /B /S mycooldiscovery.vbs

    Did you found it? I hope so;-) More info here. Now you can use Process Monitor from SystInternals to monitor your cscript vb discovery script. For more info on how to use Process Monitor go to Jeevan Bish’s blog.

    Step 5. Enable debug events in script.
    How?
    You can add a debug function to you discovery script that writes info the eventlog using oAPI.LogScriptEvent in your discovery script. For more info on using oAPI.LogScriptEvent take a look at MSDN.

    Step 6. Debug script on Agent.
    How?
    See Kevin’s post on how to do this. You can alslo take a look at Brian Wren’s Demo Store App Management on OpsManJam for an LogDebugEvent Function.

    '

    '==================================================================================
    ' Sub:        LogDebugEvent
    ' Purpose:    Logs an informational event to the Operations Manager event log
    '            only if Debug argument is true
    '==================================================================================
    Sub LogDebugEvent(EventNo,Message)

        Message = VbCrLf & Message
        If bDebug = True Then
            Call oAPI.LogScriptEvent(SCRIPT_NAME,EventNo,EVENT_LEVEL_INFO,Message)
        End If
    End Sub


    More blogposts on MP Authoring after this week of MP Authoring training.

  • MP Authoring: Extending a class attribute from a file

    Sources: Steve Rachui’s Manageability blog – ConfigMgr/OpsMgr and
                   Savision Live Maps Blog

    Is this a coincidence or what? I’ve been asked to take a look at some new blog articles from Savision about adding a ‘location’ attribute to the Windows Server class. And you can now read their first blog article How-To: Import Computer Location Information Into OpsMgr (Part 1-3) in a series of three.

    Savision explains how this can be achieved in three steps:

    1. Create a management pack that adds a ‘location’ attribute to the Windows Server class
    2. Write a connector that reads asset information from a CSV file and updates OpsMgr
    3. Configure Live Maps to create dynamic location aware maps

    Steve Rachui also extends in his blog article the class attributes from a flat file. But he uses a discovery vbscript to read the flat file instead of the connector being used/explained (in later blog posts) by Savision.

    It’s up to you what you choose to use.

    Have fun extending class attributes!

  • Reblog: Management Pack Authoring Survey

    Source: MOM Team

    The Operations Manager product group is looking for feedback on how you author custom Management Packs for System Center Operations Manager 2007, as well as areas where we can improve. Please take this survey to help guide future authoring investments.

    The survey is anonymous and should take about 10 minutes to fill out.

    Go to the MOM Team blog and fill in the survey please.

  • Using PSExec to troubleshoot OpsMgr issues

    For OpsMgr quite some people use the local system account as their Action Account. And if things are not working as expected you sometimes want to run a script or other actions under the local system account. I used to use the Task Scheduler to have scripts running under the Local System Account, but now I learned you can easily use the PSExec tool of SysInternals to do the same:-)

    How does this work?

    You can download the tool and install it on the systems you want to do your troubleshooting or just use the live share on http://live.sysinternals.com/

    I created a quick and dirty PowerShell script that writes the owner of the PowerShell process to the PowerShell eventlog.

    ##############################################################################################
    # Write Owner of PowerShell Process to PowerShell Eventlog
    # Authors: Stefan Stranger
    # ScriptName: UserAccountDebugging.ps1
    # v1.000 - 24/03/2010 - stefstr - initial sstranger's release (quick & dirty version)
    ##############################################################################################

    ##############################################################################################
    #Function Write-EventLog($Description)
    #
    #Writes Owner of PowerShell process to PowerShell Eventlog.
    ##############################################################################################
    function Write-EventLog($Description)
    {
        $source = "PowerShell(PowerShell)"
        [string]$type = "Information"
        [int]$eventid = 999
            if(![System.Diagnostics.EventLog]::SourceExists($source))
            {
                [System.Diagnostics.EventLog]::CreateEventSource($source,'Windows PowerShell')
            }
            else 
            {
                    $log = New-Object System.Diagnostics.EventLog 
                    $log.set_log("Windows PowerShell") 
                    $log.set_source($source)
                    $log.WriteEntry($Description,$type,$eventid)
            }

    }

    $processes = Get-WmiObject Win32_Process -Filter "name='powershell.exe'"
    $appendedprocesses = foreach ($process in $processes) {Add-Member -MemberType NoteProperty -Name Owner  -Value ($process.GetOwner().User) -InputObject $process -PassThru}
    $owners = ($appendedprocesses | select owner)
    foreach ($owner in $owners)
    {
        $evtdescription = "PowerShell process is being run under the next account: "  + $owner.Owner
        Write-EventLog $evtdescription
    }

    # Do whatever you wanted to do in the PowerShell script for your OpsMgr environent

    Write-Host "Hello World"

    Save above script as UserAccountDebugging.ps1.

    If we run the above script with our logged on user account we get the next result:

    image

    Result in Eventviewer

    image

     

     

    Now let’s start PSExec and run the PowerShell script with the local system account.

    Open Command prompt (as Administrator) and type: psexec –i –d –s powershell.exe

    image

    Now a new PowerShell Window will be opened as Local System Account.

    image

    Let’s now run the PowerShell script again and check the owner of the PowerShell process. Close all PowerShell sessions first ;-)

    image

    image

     

     

     

    Have fun using PSExec to debug OpsMgr Permissions issues with the local system account.