• Stefan Stranger's Weblog - Manage your IT Infrastructure

    New KBArticle: Understanding Operations Manager Maintenance Mode

    • 2 Comments

    Yesterday we published a new KBArticle about Operations Manager Maintenance Mode.

    It explains everything you want to know about Maintenance Mode.

     

    What is Maintenance Mode?

    Maintenance mode is a feature in Operations Manager to suspend monitoring of an object during regular software or hardware maintenance activities like Software Update installations, Hardware replacements, etc.

     

    Read more here.

  • Stefan Stranger's Weblog - Manage your IT Infrastructure

    CU6 for System Center Operations Manager R2 Released

    • 0 Comments

    We have released CU6 for System Center Operations Manager 2007 R2.

    Cumulative Update 6 for Operations Manager 2007 R2 includes all previous cumulative updates for Operations Manager 2007 R2 and includes all cross-platform updates.

    To download Cumulative Update 6 for Operations Manager 2007 R2, go to the following Microsoft Download Center website:

    Download Cumulative Update 6 for System Center Operations Manager 2007 R2 (http://www.microsoft.com/downloads/details.aspx?FamilyID=694147f8-9691-4833-97af-0de918c60141)

    Cumulative Update 6 for Operations Manager 2007 R2 resolves the following issues:

    • RMS promotion fails if NetworkName and PrincipalNames are not in sync for agents.
    • UI is limited to only 100 MB for the Memory Usage field in the wizard.
    • Additional OIDs in auth certificate are not processed correctly.
    • AEM creates duplicate computer objects in OpsMgr based on Agents NetBIOS name.
    • Cannot open reporting pane on OpsMgr 2007 R2 remote console.
    • Cannot view schedule for scheduled report.
    • ManagementServerConfigTool with the option "promoterms" fails because it stops polling the SDK Service.
    • OpsMgr reports are failing on Windows 7 with the error: "Cannot initialize report."
    • ACS events have "n/a" as their category in the ACS database.
    • Watch agentless monitoring listener to detect failure to respond.
    • SCOM SDK memory leak on cryptography keys and cryptography contexts.
    • After you click Edit Schedule, a message box appears, and you cannot save the change value.
    • Audit events can be lost when the AdtServer process crashes.
    Cumulative Update 6 for Operations Manager 2007 R2 resolves the following cross-platform issues:
    • The installation process for the IBM AIX 6.1 agent incorrectly checks for AIX 5.3 packages.
    • After a system restart, the OpsMgr agent for Solaris may start to run before local file systems are mounted.
    • On Red Hat Linux version 4 and SUSE Linux version 9, LVM disks are not discovered and cannot be monitored.
    • The OpsMgr agent for AIX does not report the arguments for monitored processes.
    • When Microsoft security update MS12-006 is installed on an OpsMgr management server, that management server can no longer communicate with the OpsMgr agent on any Linux or UNIX server.
    • On HP-UX, OpsMgr cannot discover and monitor a logical volume that is composed of more than 127 physical volumes.
    Cumulative Update 6 for Operations Manager 2007 R2 adds the following cross-platform features:
    • Support for IBM AIX 7.1 (POWER).
    • Support for Oracle Solaris 11 (x86 and SPARC).
    Note The new agents for IBM AIX 7.1 and Oracle Solaris 11 are included in Cumulative Update 6 for Operations Manager 2007 R2. You can download the management packs for these new operating system versions by going to the following Microsoft website:

    System Center Operations Manager 2007 R2 Cross Platform Monitoring Management Packs (http://www.microsoft.com/downloads/details.aspx?FamilyID=b15fef5c-e331-4006-8913-be376bb0e0c1)

    Technorati Tags: ,
  • Stefan Stranger's Weblog - Manage your IT Infrastructure

    PowerShell Magazine blogpost: Formatting changes for OM2012 in UR1

    • 0 Comments

    My blogpost on the formatting changes for System Center Operations Manager 2012 in Update Rollup 1 has been published on the PowerShell Magazine website.

    Take a look at my blogpost if you are interested in the PowerShell formatting changes that have been implemented after the release of UR1. Read more

    Technorati Tags: ,,
  • Stefan Stranger's Weblog - Manage your IT Infrastructure

    Check if new Management Packs have been received using PowerShell

    • 0 Comments

    Today I deployed some new Management Pack in my OM2012 demo environment, and to check if the Management Packs got deployed I checked the Operations Manager Eventlog for eventid 1201.

    And because I do this every time when I deploy new Management Packs I created a PowerShell script to check for these events. This is why we invented PowerShell Smile

     

    I wanted to know which Management Packs where deployed since the last hour. No need to retrieve all deployed Management Packs.

    $regex = [regex]'"(.*?)"'

    #Custom formatting
    $format = @{Label="MPName-Version";Expression={$regex.Matches($_.Message)}}

    get-eventlog -LogName "Operations Manager" -after (get-date).addhours(-1) |
        Where-Object {$_.Eventid -eq 1201} |
        Format-Table TimeGenerated, EventId, $format -AutoSize

     

    You can even add the –computername switch to retrieve remote eventids if you want.

    image 

  • Stefan Stranger's Weblog - Manage your IT Infrastructure

    Monitoring non-domain members with OM 2012

    • 7 Comments

    While the rest of the System Center community is in Vegas for MMS2012 I’m helping customers with their questions about System Center Operations Manager 2012. To be honest I’m little jealous on all the people who are in Vegas right now. Winking smile 

    So I created some more detailed documentation on how to start monitoring your non-domain members (workgroup servers in your DMZ) in  OM2012.

    It are still the same steps as in OM 2007 so if you already familiar with those steps it would be easy for you.

    I created a simple Diagram to have a high-level overview on which steps are being executed on which machines.

    Certificates_Workflow

      Environment:

      • OM12 RTM
      • Stand-Alone Windows Server 2008 CA (w2k8r2dc1.demo.stranger)
      • Two OM12 Management Servers (OM12MS01.demo.stranger and OM12MS02.demo.stranger)
      • Workgroup server in "DMZ" (OM12DMZ01.demo.dmz)

      Some important notes:

      • Server must have a FQDN, so if it is in a workgroup add a domain suffix manually.
      • The server being monitored must be able to resolve the FQDN of the OM2012 Management Server server.
      • Check if non-domain member server can connect to port 5723 from Management Server. (use telnet client)

      Guide info: http://technet.microsoft.com/en-us/library/dd362655.aspx

      Pre-reqs:

      It is assumed that you have AD CS installed, an HTTPS binding is being used, and its associated certificate has been installed. Information about creating an HTTPS binding is available in the topic How to Configure an HTTPS Binding for a Windows Server 2008 CA.

       

      High-Level steps:

    1. Download the Trusted Root (CA) certificate.
    2. Import the Trusted Root (CA) certificate
    3. Create a setup information file to use with the CertReq command-line utility.
    4. Create a request file.
    5. Submit a request to the CA using the request file.
    6. Approve the pending certificate request.
    7. Retrieve the certificate from the CA.
    8. Import the certificate into the certificate store.
    9. Import the certificate into Operations Manager using MOMCertImport.

      Step 1. Download the Trusted Root (CA) certificate

      • Log on to the computer where you installed a certificate; for example, the gateway server or management server.
      • Start Internet Explorer, and connect to the computer hosting Certificate Services; for example, https://<servername>/certsrv.
      • On the Welcome page, click Download a CA Certificate, certificate chain, or CRL.
      • On the Download a CA Certificate, Certificate Chain, or CRL page, click Encoding method, click Base 64, and then click Download CA certificate chain.
      • In the File Download dialog box, click Save and save the certificate; for example, Trustedca.p7b.
      • When the download has finished, close Internet Explorer.

      [OM12MS02.demo.stranger]

      Download a CA Certificate, certificate chain, or CRL

      clip_image002

      clip_image003

      clip_image004

      clip_image005

      Step 2. Import the Trusted Root (CA) Certificate

      • On the Windows desktop, click Start, and then click Run.
      • In the Run dialog box, type mmc, and then click OK.
      • In the Console1 window, click File, and then click Add/Remove Snap-in.
      • In the Add/Remove Snap-in dialog box, click Add.
      • In the Add Standalone Snap-in dialog box, click Certificates, and then click Add.
      • In the Certificates snap-in dialog box, select Computer account, and then click Next.
      • In the Select Computer dialog box, ensure that Local computer: (the computer this console is running on) is selected, and then click Finish.
      • In the Add Standalone Snap-in dialog box, click Close.
      • In the Add/Remove Snap-in dialog box, click OK.
      • In the Console1 window, expand Certificates (Local Computer), expand Trusted Root Certification Authorities, and then click Certificates.
      • Right-click Certificates, select All Tasks, and then click Import.
      • In the Certificate Import Wizard, click Next.
      • On the File to Import page, click Browse and select the location where you downloaded the CA certificate file, for example, TrustedCA.p7b, select the file, and then click Open.
      • On the File to Import page, select Place all certificates in the following store and ensure that Trusted Root Certification Authorities appears in the Certificate store box, and then click Next.
      • On the Completing the Certificate Import Wizard page, click Finish.

      [OM12MS02.demo.stranger]

      Open Certificates Local Computer account MMC:

      clip_image006

      Import Certificate TrustedCA.p7b

      clip_image007

      clip_image008

      clip_image009

      Step 3. Create a setup information file to use with the CertReq command-line utility.

      • On the computer hosting the Operations Manager component for which you are requesting a certificate, click Start, and then click Run.
      • In the Run dialog box, type Notepad, and then click OK.
      • Create a text file containing the following content:
        [NewRequest]
        Subject="CN=<FQDN of computer you are creating the certificate, for example, the gateway server or management server.>"
        Exportable=TRUE
        KeyLength=2048
        KeySpec=1
        KeyUsage=0xf0
        MachineKeySet=TRUE
        [EnhancedKeyUsageExtension]
        OID=1.3.6.1.5.5.7.3.1
        OID=1.3.6.1.5.5.7.3.2
      • Save the file with an .inf file name extension, for example, RequestConfig.inf.
      • Close Notepad.

      [OM12MS02.demo.stranger]

      clip_image010

      Step 4. Create a request file to use with a stand-alone CA

      • On the computer hosting the Operations Manager component for which you are requesting a certificate, click Start, and then click Run.
      • In the Run dialog box, type cmd, and then click OK.
      • In the command window, type CertReq –New –f RequestConfig.inf CertRequest.req, and then press ENTER.
      • Open the resulting file (for example, CertRequest.req) with Notepad. Copy the contents of this file onto the clipboard.

      [OM12MS02.demo.stranger]

      clip_image011

      Step 5. Submit a request to a stand-alone CA

      • On the computer hosting the Operations Manager component for which you are requesting a certificate, start Internet Explorer, and then connect to the computer hosting Certificate Services (for example, https://<servername>/certsrv).
      • On the Microsoft Active Directory Certificate Services Welcome screen, click Request a certificate.
      • On the Request a Certificate page, click advanced certificate request.
      • On the Advanced Certificate Request page, click Submit a certificate request by using a base-64-encoded CMC or PKCS #10 file, or submit a renewal request by using a base-64-encoded PKCS #7 file.
      • On the Submit a Certificate Request or Renewal Request page, in the Saved Request text box, paste the contents of the CertRequest.req file that you copied in step 4 in the previous procedure, and then click Submit.
      • Close Internet Explorer.

      [OM12MS02.demo.stranger]

      Request a certificate

      clip_image012

      Advanced

      clip_image013

      Select Submit a certificate request by using a base-64-encoded CMC or PKCS #10 file, or submit a renewal request by using a base-64-encoded PKCS #7 file.

      clip_image014

      clip_image015

      clip_image016

      Step 6. approve the pending certificate request

      • Log on as a certification authority administrator to the computer hosting Active Directory Certificate Services.
      • On the Windows desktop, click Start, point to Programs, point to Administrative Tools, and then click Certification Authority.
      • In Certification Authority, expand the node for your certification authority name, and then click Pending Requests.
      • In the results pane, right-click the pending request from the previous procedure, point to All Tasks, and then click Issue.
      • Click Issued Certificates, and confirm the certificate you just issued is listed.
      • Close Certification Authority.

      [W2K8R2DC1.demo.stranger]

      Click Pending Request in Certificate Authority

      clip_image017

      Click on Issue

      clip_image018

      clip_image019

      Step 7. retrieve the certificate

      • Log on to the computer where you want to install a certificate; for example, the gateway server or management server.
      • Start Internet Explorer, and connect to the computer hosting Certificate Services (for example, https://<servername>/certsrv).
      • On the Microsoft Active Directory Certificate Services Welcome page, click View the status of a pending certificate request.
      • On the View the Status of a Pending Certificate Request page, click the certificate you requested.
      • On the Certificate Issued page, select Base 64 encoded, and then click Download certificate.
      • In the File Download – Security Warning dialog box, click Save, and save the certificate; for example, as NewCertificate.cer.
      • On the Certificate Installed page, after you see the message that Your new certificate has been successfully installed, close the browser.
      • Close Internet Explorer.

      [OM12MS02.demo.stranger]

      View status of pending certificate request

      clip_image020

      Save certificate

      clip_image021

      clip_image022

      Download certificate

      clip_image023

      clip_image024

      Step 8. import the certificate into the certificate store

      • On the computer hosting the Operations Manager component for which you are configuring the certificate, click Start, and then click Run.
      • In the Run dialog box, type cmd, and then click OK.
      • In the command window, type CertReq –Accept NewCertificate.cer, and then press ENTER

      [OM12MS02.demo.stranger]

      clip_image025

      Step 9. import the certificate into Operations Manager using MOMCertImport

      • Log on to the computer where you installed the certificate with an account that is a member of the Administrators group.
      • On the Windows desktop, click Start, and then click Run.
      • In the Run dialog box, type cmd, and then click OK.
      • At the command prompt, type <drive_letter>: (where <drive_letter> is the drive where the Operations Manager 2007 installation media is located), and then press ENTER.
      • Type cd\SupportTools\i386, and then press ENTER.

      clip_image026

      Note

      On 64-bit computers, type cd\SupportTools\amd64

      • Type the following:
        MOMCertImport /SubjectName <Certificate Subject Name>
      • Press ENTER.

      [OM12MS02.demo.stranger]

      MOMCertImport /SubjectName OM12MS02.demo.stranger

      clip_image027

      Check if everything is ok

      Open the certificate that you installed on management/gateway server. Click on Details Tab and check the Serial Number.

      Now navigate to HKLM\Software\Microsoft\Microsoft Operations Manager\3.0\Machine Settings and check the value of ChannelCertificateSerialNumber. Serial number of certificate should be listed backwards here in registry.

      clip_image028

      clip_image029

      Open registry

      clip_image030

      clip_image031

      Tada!

      Pre-reqs on DMZ server:

      Make sure you have installed the OM12 Agent first before starting.

       

      clip_image039

       

      Let's check the eventlog

      clip_image041

      Repeat steps for OM12DWZ01 server in workgroup

      High-Level steps:

      • Download the Trusted Root (CA) certificate.
      • Import the Trusted Root (CA) certificate
      • Create a setup information file to use with the CertReq command-line utility.
      • Create a request file.
      • Submit a request to the CA using the request file.
      • Approve the pending certificate request.
      • Retrieve the certificate from the CA.
      • Import the certificate into the certificate store.
      • Import the certificate into Operations Manager using MOMCertImport.

      [OM12DWZ01.demo.dmz]

      Step 1. Download the Trusted Root (CA) certificate.

      clip_image042

      clip_image043

      Step 2. Import the Trusted Root (CA) certificate

      clip_image044

      Step 3. Create a setup information file to use with the CertReq command-line utility.

      clip_image045

      Step 4. Create a request file to use with a stand-alone CA

      CertReq –New –f RequestConfig.inf CertRequest.req

      clip_image046

      Step 5. Submit a request to a stand-alone CA

      clip_image047

      clip_image048

      Step 6. approve the pending certificate request

      [W2K8R2DC1.demo.stranger]

      clip_image049

      clip_image050

      Step 7. retrieve the certificate

      [OM12DMZ01.demo.dmz]

      clip_image051

      clip_image052

      Step 8. import the certificate into the certificate store

      clip_image053

      Step 9. import the certificate into Operations Manager using MOMCertImport

      MOMCertImport /SubjectName OM12DMZ01.demo.dmz

      clip_image054

      Final step is approving agent

      Check Security Settings in Operations Console.

      clip_image055

      clip_image056

      Wait for Agent to turn up in Pending Approval folder

      clip_image057

      clip_image058

      End result:

      clip_image059

     

    Have fun at MMS for those who are in Vegas, and for those who are not, well…

  • Stefan Stranger's Weblog - Manage your IT Infrastructure

    Released - Technical Documentation Download for System Center 2012 – Operations Manager

    • 1 Comments

    Just a short blogpost to let you know we released the Technical Documentation Download for System Center 2012 – Operations Manager. Go to Microsoft Download Center and download the following documentation.

    Overview

    The downloadable files listed on this page contain the product documentation for the Operations Manager component of System Center 2012. The available downloads include:

    • Authoring Guide for System Center 2012 - Operations Manager - last updated April 1, 2012
    • Deployment Guide for System Center 2012 - Operations Manager - last updated April 1, 2012
    • Operations Guide for System Center 2012 - Operations Manager - last updated April 1, 2012
    • System Center 2012 – Operations Manager Cmdlet Reference - last updated April 1, 2012

     

    And for you lazy people who don’t want to click for each download I again created a PowerShell script to download them all in on go Winking smile

    ###############################################################################
    # Download all OM12 Documents from
    # http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=29256
    # in one-go using PowerShell and BitsTransfer.
    # Remark: Use PowerShell 2.0 because it makes use of the BitsTransfer Module
    # Author: Stefan Stranger
    # v1.002 - 01/04/2012 - stefstr - second release
    ###############################################################################

    $outputfolder = "c:\Temp\OM12Docs"

    Import-Module BitsTransfer #Loads the BitsTransfer Module
    Write-Host "BitsTransfer Module is loaded"

    $OM12Docs = @("http://download.microsoft.com/download/3/3/F/33F52373-3A75-422C-969B-61E05EEC5E72/SC2012_OpsMgr_Operations.docx",
                        "http://download.microsoft.com/download/3/3/F/33F52373-3A75-422C-969B-61E05EEC5E72/SC2012_OpsMgr_Authoring.docx",
                        "http://download.microsoft.com/download/3/3/F/33F52373-3A75-422C-969B-61E05EEC5E72/SC2012_OpsMgr_Cmdlets.doc",
                        "http://download.microsoft.com/download/3/3/F/33F52373-3A75-422C-969B-61E05EEC5E72/SC2012_OpsMgr_Deployment.docx")
    Foreach ($OMDoc in $OM12Docs) { Start-BitsTransfer -source $OMDoc -Destination $outputfolder}
    Write-Host "OM12 Docs are downloaded to $outputfolder"

  • Stefan Stranger's Weblog - Manage your IT Infrastructure

    Microsoft Script Explorer for Windows PowerShell (pre-release)

    • 0 Comments

    Today we released the Microsoft Script Explorer for Windows PowerShell (pre-release).

    Microsoft Script Explorer for Windows PowerShell (pre-release) helps scripters find Windows PowerShell scripts, snippets, modules, and how-to guidance in online repositories such as the TechNet Script Center Repository, PoshCode, local or network file systems and Bing Search Repository.

    System requirements

    Supported Operating Systems: Windows 7 Service Pack 1, Windows 8 Consumer Preview, Windows Server 2008 R2 SP1, Windows Server 2008 Service Pack 2, Windows Server 8 Beta, Windows Vista Service Pack 2

    Additional Requirements:

    • Windows PowerShell 2.0/3.0 ISE (Client computer that is to run Script Explorer as an add-on)
    • Microsoft .NET Framework 4

    Additional information

    This software is a pre-release version. Features and behavior are likely to change before the final release.
    This preview release is designed to enable the community to experience and review the preliminary designs and direction of key features in Microsoft Script Explorer and to solicit feedback before features are finalized. If you have additional questions, need help in troubleshooting issues, and other product features visit the Microsoft Script Explorer Forum on TechNet. Your feedback is important to us. Help improving Script Explorer by submitting bugs and suggestions to Microsoft Script Explorer Forum on TechNet.

    image

     

    image

     

    And start searching for your PowerShell scripts.

    image

     

    Please give use feedback on the Microsoft Script Explorer Forum on TechNet.

    Thanks!

  • Stefan Stranger's Weblog - Manage your IT Infrastructure

    OM12 - Creating a Dashboard View with Widgets and store in specific Management Pack

    • 0 Comments

    Today I was playing around with creating some Dashboard Views with Widgets and wanted to store them in their own Management Pack. All the blogs about creating OM 2012 Dashboards store the Dashboards and Widgets in the Default Management Pack. This is by design because all Views (and the Dashboard View is just another view) are created in the folder you started doing it from.

    The only exception to this, is creating a folder (but that’s not a view Winking smile)

    So if you start creating a Dashboard View in the Monitoring folder the Dashboard View is stored in the Default Management Pack.

    image

    If you want to store your Dashboard View in another Management Pack than the Default Management Pack, you need to create a new Management Pack (for example create a Test Management Pack) and start creating your Dashboard View under that (Test) folder.

    image

    Now your Dashboard View is being stored in the Test Management Pack.

     

    More blogposts about creating Dashboard views are:

  • Stefan Stranger's Weblog - Manage your IT Infrastructure

    OM12 - Viewing contents Management Pack Bundle files with MPViewer 1.9

    • 0 Comments

    Yesterday I blogged about some small improvements to Daniele Grandini blogpost about a great PowerShell script to dump the contents of Management Pack Bundles (.mpb) files and the old MP contents.

    But did you knew you can do the same with the new MP Viewer Daniele Muscetta created for OM12?

     

    With MPViewer 1.9 you can also view the contents of mpb (MP Bundles). How cool is that?

    image

     

    After you opened the mpb file go to the Resources folder and BOOM! there you see the contents of the mpb files. How cool is that?

    image

    Or some script info like the sql queries

    image

    Go get the latest OM12 tools from Daniele Muscetta’s blogpost.

  • Stefan Stranger's Weblog - Manage your IT Infrastructure

    OpsMgr 2012 – how to dump management pack bundles (small “improvement”)

    • 2 Comments

    Last week Daniele Grandini posted a great PowerShell script to dump the contents of Management Pack Bundles (.mpb) files and the old MP contents.

    The script takes just two parameters an input directory where you have to copy MP and MPB files and an output directory where the dumps will be saved. The OpsMgr 2012 admin console needs to be installed for the script to work properly.

    Today I finally had some time to play with OM12 and PowerShell for a session I’m preparing and I also tried to Daniele’s dump management pack bundles PowerShell script. It worked as expected, but the results of the dumped mpb files where stored in the same directory together with all other dumped mpb file contents. And this is not what I wanted.

    image

     

    I would rather have the contents of each dumped mpb file stored in it’s own folder. That way it’s easier to explore the contents of the mpb file IMO.

    So I made some small changes to the PowerShell script Daniele created to have each mpb file dump it’s content in it’s own folder.

    image

    Now it’s easier to see what has been dumped for each mpb file.

    I hope Daniele won’t mind me changing his script slightly to fit my personal preferences Smile 

    Here is my changed version of Daniele’s script:

    param($inDir, $outDir)

    [Reflection.Assembly]::LoadWithPartialName("Microsoft.EnterpriseManagement.Core")
    [Reflection.Assembly]::LoadWithPartialName("Microsoft.EnterpriseManagement.Packaging")

    $mpStore = new-Object Microsoft.EnterpriseManagement.Configuration.IO.ManagementPackFileStore($inDir)

    $mps = get-childitem $inDir *.mp
    #$mpWriter = new-object Microsoft.EnterpriseManagement.Configuration.IO.ManagementPackXmlWriter($outDir)
    if ($mps -ne $null)
    {
        foreach ($file in $mps)
        {
            md ($outDir + "\"+ $file)  #ADDED     
            $mpWriter = new-object Microsoft.EnterpriseManagement.Configuration.IO.ManagementPackXmlWriter($outDir + "\"+ $file) #ADDED
            $MPFilePath = $file.FullName
            $mp = new-object Microsoft.EnterpriseManagement.Configuration.ManagementPack($MPFilePath)
            Write-Host $file
            $mpWriter.WriteManagementPack($mp)
        }
    }
    #now dump MPB files
    $mps = get-childitem $inDir *.mpb
    $mpbReader = [Microsoft.EnterpriseManagement.Packaging.ManagementPackBundleFactory]::CreateBundleReader()
    if ($mps -ne $null)
    {
        foreach ($file in $mps)
        {
            md ($outDir + "\"+ $file)  #ADDED     
            $mpWriter = new-object Microsoft.EnterpriseManagement.Configuration.IO.ManagementPackXmlWriter($outDir + "\"+ $file)    #ADDED   
            $mpb = $mpbReader.Read($file.FullName, $mpStore)
            foreach($mp in $mpb.ManagementPacks)
            {
                #write the xml
                $mpWriter.WriteManagementPack($mp)
                $streams = $mpb.GetStreams($mp)
                foreach($stream in $streams.Keys)
                {
                    $mpElement = $mp.FindManagementPackElementByName($stream)
                    $fileName = $mpElement.FileName
                    if ($fileName -eq $null)
                    {
                        $fileName = $outDir +'\' + ($mp.Name)+ '.' + $stream+ '.bin'
                    }
                    else
                    {
                        If ($fileName.IndexOf('\') -gt 0)
                        {
                            #only on dir level supported
                            $dir = $outDir + '\' + $fileName.SubString(0, $fileName.IndexOf('\'))
                            if ([System.Io.Directory]::Exists($dir) -ne $true)
                            {
                                [System.Io.Directory]::CreateDirectory($dir)
                            }
                        }
                        #$fileName = "${outdir}\${fileName}"
                        $fileName = $outdir+"\"+$file+"\$filename" #ADDED
                    }
                    Write-Host "`t$fileName"
                    $fs = [system.io.file]::Create($fileName)
                    $streams[$stream].WriteTo($fs)
                    $fs.Close()
                }
            }
        }
    }

     

    See the comment # for what I changed.

     

    This posting is provided "AS IS" with no warranties, and confers no rights.

  • Stefan Stranger's Weblog - Manage your IT Infrastructure

    Everything you want to know about the OM12 Cmdlets

    • 2 Comments

    Did you know there is a help topic about which cmdlets are new to Operations Manger 2012, which Operations Manager 2007 cmdlets have an equivalent Operations
    Manager 2012 cmdlet ("renamed" cmdlets), and Operations Manager 2007 cmdlets that have no Operations Manager 2012 equivalent ("deprecated" cmdlets)?

    Yes there is Smile Just type Get-Help about_OpsMgr_Cmdlet_Names

    image

     

    Here it is:

    TOPIC
        about_OpsMgr_Cmdlet_Names

    SHORT DESCRIPTION
        Maps the System Center Operations Manager 2007 cmdlets to the
        Operations Manager 2012 cmdlets.


    LONG DESCRIPTION
        All cmdlets in Operations Manager 2012 have new names, and can be
        identified by the "SC" preceding the noun name. In some cases, the
        verb associated with the cmdlet has also been updated.

        This topic outlines which cmdlets are new to Operations Manger 2012,
        which Operations Manager 2007 cmdlets have an equivalent Operations
        Manager 2012 cmdlet ("renamed" cmdlets), and Operations Manager 2007
        cmdlets that have no Operations Manager 2012 equivalent ("deprecated"
        cmdlets).

        ------------------------------------------------------------------------
        OPERATIONS MANAGER 2012 MODULE NAME
        ------------------------------------------------------------------------
       
        Operations Manager 2007 snap-in   
        Microsoft.EnterpriseManagement.OperationsManager.Client

        Operations Manager 2012 module
        OM10

        ------------------------------------------------------------------------
        NEW OPERATIONS MANAGER 2012 CMDLETS
        ------------------------------------------------------------------------

        Enable-SCOMAgentProxy
        Disable-SCOMAgentProxy
        Enable-SCOMDiscovery
        Disable-SCOMDiscovery
        Set-SCOMManagementGroupConnection   
        Enable-SCOMMonitor
        Disable-SCOMMonitor
        Enable-SCOMMonitoringRule
        Disable-SCOMMonitoringRule
        Get-SCOMRunAsProfile
        Update-SCOMRunAsProfile

        ------------------------------------------------------------------------
        RENAMED CMDLETS
        ------------------------------------------------------------------------

        Operations Manager 2007 Name         Operations Manager 2012 Name
        ----------------------------                           ---------------------------- 
        Get-Agent                                                  Get-SCOMAgent
        Install-Agent                                             Install-SCOMAgent
        Uninstall-Agent                                        Uninstall-SCOMAgent
        Approve-AgentPendingAction               Approve-SCOMPendingManagement
        Get-AgentPendingAction                        Get-SCOMPendingManagement
        Reject-AgentPendingAction                   Deny-SCOMPendingManagement
        Get-Alert                                                    Get-SCOMAlert
        Resolve-Alert                                            Set-SCOMAlert
        Set-AlertDestination                               Set-SCOMAlert
        Get-AlertHistory                                      Get-SCOMAlertHistory
        Get-Connector                                         Get-SCOMConnector
        Get-Diagnostic                                         Get-SCOMDiagnostic
        Remove-DisabledMonitoringObject    Remove-SCOMDisabledClassInstance
        Get-Discovery                                           Get-SCOMDiscovery
        Get-Event                                                  Get-SCOMEvent
        Get-FailoverManagementServer          Get-SCOMAgentManagementServerSetting
        Get-GatewayManagementServer        Get-SCOMGatewayManagementServer
        Get-MaintenanceWindow                     Get-SCOMMaintenanceMode
        New-MaintenanceWindow                    Start-SCOMMaintenanceMode
        Set-MaintenanceWindow                      Update-SCOMMaintenanceMode
        Get-ManagementGroupConnection    Get-SCOMManagementGroupConnection
        New-ManagementGroupConnection    New-SCOMManagementGroupConnection
        Remove-ManagementGroupConnection    Remove-SCOMManagementGroupConnection
        Export-ManagementPack                       Export-SCOMManagementPack
        Get-ManagementPack                            Get-SCOMManagementPack
        Install-ManagementPack                        Import-SCOMManagementPack
        Uninstall-ManagementPack                   Remove-SCOMManagementPack
        Get-ManagementServer                          Get-SCOMManagementServer
        Set-ManagementServer                          Set-SCOMAgentManagementServerSetting
        Set-ManagementServer                          Set-SCOMAgentManagementServerSetting
        Get-Monitor                                              Get-SCOMMonitor
        Get-MonitorHierarchy                            Get-SCOMMonitor
        Get-MonitoringClass                               Get-SCOMClass
        Get-MonitoringObject                            Get-SCOMClassInstance
        Get-MonitoringObjectGroup                 Get-SCOMGroup
        Get-NotificationAction                          Get-SCOMNotificationAction
        Get-NotificationEndpoint                      Get-SCOMNotificationEndpoint
        Get-NotificationRecipient                     Get-SCOMNotificationRecipient
        Disable-NotificationSubscription         Disable-SCOMNotificationSubscription
        Enable-NotificationSubscription          Enable-SCOMNotificationSubscription
        Get-NotificationSubscription                Get-SCOMNotificationSubscription
        Get-Override                                             Get-SCOMOverride
        Get-PrimaryManagementServer           Get-SCOMAgentManagementServerSetting
        Set-ProxyAgent                                         Set-SCOMAgentlessManagedComputer
        Get-Recovery                                            Get-SCOMRecovery
        Get-RelationshipClass                             Get-SCOMRelationship
        Get-RelationshipObject                          Get-SCOMRelationshipInstance
        Add-RemotelyManagedComputer        Add-SCOMAgentlessManagedComputer
        Get-RemotelyManagedComputer        Get-SCOMAgentlessManagedComputer
        Remove-RemotelyManagedComputer    Remove-SCOMAgentlessManagedComputer
        Get-ResultantCategoryOverride           Get-SCOMOverride
        Get-ResultantRuleOverride                    Get-SCOMOverride
        Get-ResultantUnitMonitorOverride     Get-SCOMOverride
        Get-Rule                                                     Get-SCOMMonitoringRule
        Get-RunAsAccount                                   Get-SCOMRunAsAccount
        Get-Task                                                    Get-SCOMTask
        Start-Task                                                   Start-SCOMTask
        Get-TaskResult                                         Get-SCOMTaskResult
        Get-UserRole                                            Get-SCOMUserRole
        Add-UserToUserRole                              Update-SCOMUserRole


        ------------------------------------------------------------------------
        DEPRECATED OPERATIONS MANAGER 2007 CMDLETS
        ------------------------------------------------------------------------

        Install-AgentByName
        Get-AlertDestination
        Remove-ConnectorFromTier
        Add-ConnectorToTier
        New-CustomMonitoringObject
        Get-DefaultSetting
        Set-DefaultSetting
        New-DeviceDiscoveryConfiguration
        Get-Diagnostic
        Start-Discovery
        New-LdapQueryDiscoveryCriteria
        Get-MonitoringClassProperty
        Get-MonitoringObjectPath
        Get-MonitoringObjectProperty
        New-MonitoringPropertyValuePair
        Get-NotificationAction
        Get-NotificationEndpoint
        Get-NotificationRecipient
        Disable-NotificationSubscription
        Enable-NotificationSubscription
        Get-NotificationSubscription
        Get-OperationsManagerCommand
        Get-PerformanceCounter
        Get-PerformanceCounterValue
        Get-Recovery
        Add-RemotelyManagedDevice
        Get-RemotelyManagedDevice
        Remove-RemotelyManagedDevice
        Get-RootManagementServer
        Disable-Rule
        Enable-Rule
        Get-State
        Get-Tier
        New-Tier
        Remove-Tier
        New-WindowsDiscoveryConfiguration
       

    SEE ALSO
        about_OpsMgr_WhatsNew

  • Stefan Stranger's Weblog - Manage your IT Infrastructure

    Inside Central Podcasts–Episode 12–OpsMgr 2012 Command Shell

    • 2 Comments

    Last week I had to some long car drives to one of our customers and had plenty of time to listen to some of my favorite podcasts like the PowerScripting Podcasts and Inside Central Podcasts. And in Episode 12 both of my favorite topics where discussed, PowerShell and Operations Manager.

    In this episode Pete Zerger and Dan Kregor discuss some of the changes you can expect to see to the Command Shell in OpsMgr 2012. And to my surprise they mentioned some of the PowerShell and OM12 stuff I blogged about Smile 

    And  because I love to dive into the new OM12 Cmdlets and Functions here some more things to explore.

    If you looked at my blogpost about what’s new in OM12 for PowerShell you may have noticed that in OM12 we don’t have the Resolve-Alert in OM12. We now have the Set-SCOMAlert Cmdlet.

    If we look at the help for the Set-SCOMAlert Cmdlet we see the following:

    get-help Set-SCOMAlert

    NAME
        Set-SCOMAlert
       
    SYNOPSIS
        Changes the properties of the specified alert.
       
       
    SYNTAX
        Set-SCOMAlert [-Alert] <MonitoringAlert[]> [[-CustomField7] <String>] [[-CustomField8] <String>] [[-CustomField9] <String>] [[-Owner] <String>] [[-ResolutionState] <Byte>] [[-TicketId] <String>] [[-Connector] <MonitoringConnector>] [[-CustomField1] <Strin
        g>] [[-CustomField10] <String>] [[-CustomField2] <String>] [[-CustomField3] <String>] [[-CustomField4] <String>] [[-CustomField5] <String>] [[-CustomField6] <String>] [-Confirm [<SwitchParameter>]] [-WhatIf [<SwitchParameter>]] [<CommonParameters>]
       
       
    DESCRIPTION
        The Set-SCOMAlert cmdlet changes the properties of the specified alert.
       

    RELATED LINKS
        Online Version: http://go.microsoft.com/fwlink/?LinkID=187701
        Get-SCOMAlert
        Get-SCOMConnector

    REMARKS
        To see the examples, type: "get-help Set-SCOMAlert -examples".
        For more information, type: "get-help Set-SCOMAlert -detailed".
        For technical information, type: "get-help Set-SCOMAlert -full".

    Do you see there is no Comment property like we had in the OpsMgr 2007 Resolve-Alert Cmdlet?

    Look at the examples:

    get-help Set-SCOMAlert -examples

    NAME
        Set-SCOMAlert
       
    SYNOPSIS
        Changes the properties of the specified alert.
       
        -------------------------- EXAMPLE 1 --------------------------
       
        PS C:\>Get-SCOMAlert -ResolutionState 15 | Set-SCOMAlert -ResolutionState 255
       
       
        Description
        -----------
        This command gets all alerts with a resolution state of 15 and then uses the pipeline operator (|) to pass the alert objects to the Set-SCOMAlert cmdlet which closes the alert by setting the resolution state to 255.
        -------------------------- EXAMPLE 2 --------------------------
       
        PS C:\>Get-SCOMAlert -Name "Failed Accessing Windows Event Log" | Set-SCOMAlert -Owner "CONTOSO\Isabel" -CustomField1 "Root Cause - Permissions"
       
       
        Description
        -----------
        This command gets all alerts named "Failed Accessing Windows Event Log" and then uses the pipeline operator to pass the alert objects to the Set-SCOMAlert cmdlet which changes the owner and sets the value for CustomField1.

     

    When we look at the help for the OpsMgr 2007 R2 Resolve-Alert Cmdlet we see the following:

    >get-help resolve-alert

    NAME
        Resolve-Alert

    SYNOPSIS
        Resolves an alert.


    SYNTAX
        Resolve-Alert [-Alert] <MonitoringAlert> [[-Comment] [<String>]] [-WhatIf] [-Confirm] [<CommonParameters>]


    DESCRIPTION
        Resolves an alert.


    RELATED LINKS
        Get-Alert
        Get-AlertHistory

    REMARKS
        To see the examples, type: "get-help Resolve-Alert -examples".
        For more information, type: "get-help Resolve-Alert -detailed".
        For technical information, type: "get-help Resolve-Alert -full".

    This Cmdlet has different parameters then the Set-SCOMAlert Cmdlet, so we need to find some workarounds to solve this.

    If we still want to use the Resolve-Alert Cmdlet in OM12 we can easily create a function that does the same as the old Resolve-Alert Cmdlet. We just need to use Set-SCOMAlert with a ResolutionState of 255  to achieve the same result as
    the old resolve-alert cmdlet.

    Open your favorite PowerShell Editor and create a new Resolve-SCOMAlert Function.

    <#
    .SYNOPSIS
       Resolves an Alert
    .DESCRIPTION
       Resolves an Alert
    .PARAMETER Alert
       Specifies the alert to resolve. You can use Get-Alert to create an object to pass as the value of this parameter.
    .PARAMETER Comment
       Specifies a comment to associate with the resolved alert.
    .PARAMETER WhatIf
        Describes what would happen if you executed the command without actually executing the command.
    .PARAMETER Confirm
        Prompts you for confirmation before executing the command.
    .EXAMPLE
       C:\PS\get-SCOMalert | where-object {$_.Owner -eq "kenmeyers"} |
           resolve-SCOMalert -comment "Resolving all of Ken's alerts."
       
        This command uses Get-SCOMAlert to retrieve all alerts. It then pipes the results to Where-Object to only select the ones owned by Ken Meyers. The alerts that pass the filter are piped to Resolve-SCOMAlert to be resolved with the comment, "Resolving all of Ken's alerts."
    .EXAMPLE
        C:\PS>$alerts = get-scomalert |
        where-object {$_.ResolutionState -eq 0}

        foreach($alert in $alerts)
        {
           resolve-alert -comment "Resolving Alert" -Alert $alert
        }


        This command uses Get-Alert to retrieve unresolved alerts. Unresolved alerts have a resolution state equal to 0. The command then loops through all the unresolved alerts, calling Resolve-Alert to resolve each of them. The comment "Resolving Alert" is associated with each resolved alert.
    #>

     

    function Resolve-SCOMAlert {
    <#
    -Mandatory  - a boolean saying whether the parameter is required or not. A mandatory parameter that is not specified generates a run time exception.
    -Position – an integer specifying where parameter’s order. As you can see in the above example, the $User paramater is the third parameter, while $domain is the first and $computer the second.
    -ValueFromPipeline – a boolean indicating if the parameter can come from the pipeline.
    #>
    [CmdletBinding()]
    PARAM(
       [Parameter(Position=0, ValueFromPipeline=$true, Mandatory=$true)]
       $Alert
    ,
       [Parameter(ValueFromPipeline=$true,Mandatory=$false)]
       [AllowEmptyString()]
       [string]$Comment
    ,
       [Parameter(Mandatory=$false)]
       [boolean]$Whatif
    ,
       [Parameter(Mandatory=$false)]
       [boolean]$Confirm
     
    )

       #Set Resolutionstate Parameter for Set-SCOM Alert
       $RState = "255"
       set-variable $RState -option constant # The constant option write protect the resolutionstate property.

    # Call now the Set-SCOMAlert with the default parameter –ResolutionState 255
        if ($PSBoundParameters.TryGetValue('Comment', [ref]$Comment))
            {
                #There is no Comment Parameter in the Set-SCOMAlert Cmdlet, so we use CustomField1 for the Comment.
                $PSBoundParameters.Remove('Comment') | Out-Null
                $PSBoundParameters.Add('CustomField1', $Comment)
            }

        #Call the new OM12 Set-SCOMAlert Cmdlet with the correct parameters
        Set-SCOMAlert @psboundparameters -ResolutionState $RState
    }

    We start the new function with some help info. I just copied the help info from the old Resolve-Alert Cmdlet and only changed Resolve-Alert to the new naming convention in OM12 Resolve-SCOMAlert.

    Then I created a new Function called Resolve-SCOMAlert, which has the same parameters as the old Resolve-Alert Cmdlet, with a default value of 255 for the ResolutionState parameter.

    Because the Set-SCOMAlert is missing the Comment property we need to remove the Comment parameter from the $PSBoundParameters and replace that with a new CustomField1 property.

     

    Ok, let’s check if our new Resolve-SCOMAlert Function is working the same as our old Resolve-Alert Cmdlet in OpsMgr 2007.

    Open the Operations Console and pick an Alert we want to resolve.

    image

    We are going to resolve the “IIS Restart is required” Alert using our new Resolve-SCOMAlert function.

    Open the Operations Manager Shell and load the new Resolve-AlertSCOM Function by dotsourcing the above script.

    image

    We can now show the help of the new Resolve-SCOMAlert function with the usual get-help cmdlet.

    image

    Now we can try to use the resolve-scomalert function on our “IIS Restart is required”

    We first need to get the “IIS Restart is required” alert using the new OM12 Get-SCOMAlert Cmdlet.

    image

    When we use some formatting and extra properties we see that this is our Alert we want to resolve.

    image

    The final step is resolve this alert and add a comment.

    get-scomalert | where {$_.Name -eq "IIS Restart is required"} | resolve-SCOMAlert -Comment "Resolved with new Resolve-SCOMAlert Function"

    image

    Now let’s check if our Alert is being resolved and has the Comment in CustomField1.

    image

    It worked! Smile

    If you want to use the Whatif or the Confirm parameter you just need to add $true after those parameters. Example:
    image

    image

     

    Disclamer:  Posts in this blog are provided "AS IS" with no warranties, and confers no rights. Included script is an example script.

  • Stefan Stranger's Weblog - Manage your IT Infrastructure

    Reformatting get-scomrmsemulator cmdlet output

    • 2 Comments

    Hi people I need your help. Today I was looking at the Get-SCOMRMSEmulator cmdlet in OM12 RC and noticed that when running this Cmdlet I got the following WARNING: column "Id" does not fit into the display and was removed"

     

    clip_image002

    I solved it by using the Format-Table Autosize cmdlet, but would not it be better if this Warning is not shown when running the cmdlet?

    So I created a Suggestion on Microsoft Connect to get this fixed. So please vote on Connect if you also want us to fix this for the next release.

    I also suggested to remove the Id property from the default output shown. This is not adding any valuable information about the RMS Emulator anyway. (to my knowledge)

    Maybe you can suggest better properties to show.

    clip_image002[4]

     

    Thanks!

    /Stefan

  • Stefan Stranger's Weblog - Manage your IT Infrastructure

    Do OM12 Management Servers have different registry keys?

    • 2 Comments

    Now everybody has downloaded OM12 Release Candidate, it’s time to start exploring. Let’s start exploring the registry of the Management Servers for OM12.

    And off course we are going to use PowerShell to browse through the OM12 Registry.

    Let’s open the registry for OM12 on our first Management Server by starting PowerShell with the Run as Administrator option.

    cd "HKLM:\SOFTWARE\Microsoft\Microsoft Operations Manager"

    get-childitem –recursive

    image

     

    With the following command we get the properties of the different registry keys.

    First set the  $ErrorActionPreference = silentlycontinue (this will make sure we don’t see any error messages, which I got due to an issue with long file names)

    Get-ChildItem 'hklm:\software\microsoft\microsoft operations manager' -Recurse | ForEach-Object {Get-ItemProperty $_.pspath}

     

    image

    image

     

    But would not it be nice to compare the registry keys between two Management Servers?

    I found that exporting the registry keys using Regedit and than using the Compare-Object cmdlet was the easiest way to use.

     

    You can use the following command to export the Microsoft Operations Manager keys.

    regedit /e d:\temp\exportregkeyserver1.reg "HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\Microsoft Operations Manager"

    image

    Just use the same command (only change the name of the file you want to export the registry key to) on your other Management Server and copy the result to your first Management Server.

    Now we can use the Compare-Object Cmdlet to compare the different Registry keys from the two Management Servers.

    Compare-Object $(Get-Content "D:\temp\exportregkeyserver1.reg") $(Get-Content "D:\temp\exportregkeyserver2.reg") | ft –wrap

    image

     

    So the most important differences between the Management Server I installed first and the second Management Server is the Reporting Key:

    get-itemproperty "hklm:\software\microsoft\microsoft operations Manager\3.0\Reporting"

    image

     

    Don’t forget to change you $ErrorActionPreference = continue

    Have fun exploring OM12 Winking smile

  • Stefan Stranger's Weblog - Manage your IT Infrastructure

    New System Center 2012 Virtual Labs available

    • 0 Comments

    Source: System Center Central

    Now that we have released System Center 2012 Release Candidate is time to start installing this release in you test environment.

    But you can already start using our Technical Virtual Labs.

    TechNet Virtual Labs enable you to quickly evaluate and test Microsoft's newest products and technologies through a series of guided, hands-on labs that you can complete in 90 minutes or less. There is no complex setup or installation required, and you can use TechNet Virtual Labs online immediately, free.

     

    Sorry for not being able to post some blogposts lately, but I’m just too busy ramping up on all our new products Winking smile

  • Stefan Stranger's Weblog - Manage your IT Infrastructure

    How to find out what’s new in OM12 for PowerShell

    • 1 Comments

    This week I started to play with Windows 8 and of course one of the first things I looked for was PowerShell 3.0 Smile And then I found a great blogpost on the PowerShellMagazine website by Shay Levy where he shows how find all the changes between the two versions of PowerShell (v2 and v3).

    That’s when I thought why not use the same approach for finding the changes between the OpsMgr 2007 R2 PowerShell Commands and the OM12 PowerShell Commands.

    This is the script I slightly modified to get it to work for OpsMgr 2007 and OM12.

    # Compare differences OpsMgr 2007 PowerShell Commands and OM 12 PowerShell Commands.
    # Idea and initial script from Shay Levy on PowerShellMagazine. (http://www.powershellmagazine.com/2011/09/15/how-to-find-out-whats-new-in-powershell-vnext)
    # Small changes by Stefan Stranger
    # Date: 21-09-2011

    #Run in OpsMgr 2007 Command Shell
    Get-Command -Module Microsoft.EnterpriseManagement.OperationsManager.Client | Select-Object -Property Name,@{Name='Parameters';Expression={(Get-Command $_).Parameters.Keys}} | Export-Clixml d:\temp\opsmgr2007.xml

    #Run in OM12 Command Shell
    Get-Command -Module OperationsManager | Select-Object -Property Name,@{Name='Parameters';Expression={(Get-Command $_).Parameters.Keys}} | Export-Clixml d:\temp\om12.xml


    # run either in OpsMgr2007  or OM12 console
    $OpsMgr2007 = Import-CliXml d:\temp\opsmgr2007.xml | Sort-Object -Property Name
    $OM12 = Import-CliXml d:\temp\om12.xml | Sort-Object -Property Name

    Compare-Object $OpsMgr2007 $OM12 -Property Name -IncludeEqual -PassThru | ForEach-Object {

        $Command = $_

        if($_.SideIndicator -eq ‘==’)
        {
            $Command = $_

            $cOpsMgr2007 = $OpsMgr2007  | Where-Object {$_.Name -eq $Command.Name} | Select-Object -ExpandProperty Parameters
            $cOM12 = $OM12 | Where-Object {$_.Name -eq $Command.Name} | Select-Object -ExpandProperty Parameters

            $compare = Compare-Object $cOpsMgr2007  $cOM12

            if($compare)
            {
                try
                {
                    $NewParameters = $compare | Where-Object {$_.SideIndicator -eq ‘=>’} | ForEach-Object {$_.InputObject + ‘ (+)’}
                    $RemovedParameters = $compare | Where-Object {$_.SideIndicator -eq ‘<=’} | ForEach-Object {$_.InputObject + ‘ (-)’}

                    “$($command.Name) (!)”
                    $NewParameters + $RemovedParameters | Sort-Object | ForEach-Object { “`t$_”}
                    “`n”
                }
                catch{}
            }
        }
        elseif($_.SideIndicator -eq ‘=>’)
        {
            “$($Command.name) (+)`n”
        }
        else
        {
            “$($Command.name) (-)`n”
        }
    }

     

    OpsMgr 2007 Command Shell

    image

     

    OM12 Command Shell

    image

     

    Legend

    > Changed
    + > New
    - > Removed

     

    Add-ConnectorToTier (-) Get-RelationshipClass (-) Import-SCManagementPack (+)
    Add-RemotelyManagedComputer (-) Get-RelationshipObject (-) Import-SCOMManagementPack (+)
    Add-RemotelyManagedDevice (-) Get-RemotelyManagedComputer (-) Install-Agent (-)
    Add-SCOMAgentlessManagedComputer (+) Get-RemotelyManagedDevice (-) Install-AgentByName (-)
    Add-UserToUserRole (-) Get-ResultantCategoryOverride (-) Install-ManagementPack (-)
    Approve-AgentPendingAction (-) Get-ResultantRuleOverride (-) Install-SCOMAgent (+)
    Approve-SCOMPendingManagement (+) Get-ResultantUnitMonitorOverride (-) New-CustomMonitoringObject (-)
    Deny-SCOMPendingManagement (+) Get-RootManagementServer (-) New-DeviceDiscoveryConfiguration (-)
    Disable-NotificationSubscription (-) Get-Rule (-) New-LdapQueryDiscoveryCriteria (-)
    Disable-Rule (-) Get-RunAsAccount (-) New-MaintenanceWindow (-)
    Disable-SCOMAgentProxy (+) Get-SCClass (+) New-ManagementGroupConnection (-)
    Disable-SCOMDiscovery (+) Get-SCDiscovery (+) New-MonitoringPropertyValuePair (-)
    Disable-SCOMMonitor (+) Get-SCManagementGroupConnection (+) New-SCManagementGroupConnection (+)
    Disable-SCOMNotificationSubscription (+) Get-SCManagementPack (+) New-SCOMManagementGroupConnection (+)
    Disable-SCOMRule (+) Get-SCOMAccessLicense (+) New-SCOMResourcePool (+)
    Enable-NotificationSubscription (-) Get-SCOMAgent (+) New-Tier (-)
    Enable-Rule (-) Get-SCOMAgentlessManagedComputer (+) New-WindowsDiscoveryConfiguration (-)
    Enable-SCOMAgentProxy (+) Get-SCOMAgentManagementServerSetting (+) Reject-AgentPendingAction (-)
    Enable-SCOMDiscovery (+) Get-SCOMAlert (+) Remove-ConnectorFromTier (-)
    Enable-SCOMMonitor (+) Get-SCOMAlertHistory (+) Remove-DisabledMonitoringObject (-)
    Enable-SCOMNotificationSubscription (+) Get-SCOMClass (+) Remove-ManagementGroupConnection (-)
    Enable-SCOMRule (+) Get-SCOMClassInstance (+) Remove-RemotelyManagedComputer (-)
    Export-ManagementPack (-) Get-SCOMCommand (+) Remove-RemotelyManagedDevice (-)
    Export-SCManagementPack (+) Get-SCOMConnector (+) Remove-SCManagementGroupConnection (+)
    Export-SCOMEffectiveMonitoringConfiguration (+) Get-SCOMDiagnostic (+) Remove-SCManagementPack (+)
    Export-SCOMManagementPack (+) Get-SCOMDiscovery (+) Remove-SCOMAgentlessManagedComputer (+)
    Get-Agent (-) Get-SCOMEvent (+) Remove-SCOMDisabledClassInstance (+)
    Get-AgentPendingAction (-) Get-SCOMGatewayManagementServer (+) Remove-SCOMManagementGroupConnection (+)
    Get-Alert (-) Get-SCOMGroup (+) Remove-SCOMManagementPack (+)
    Get-AlertDestination (-) Get-SCOMMaintenanceMode (+) Remove-SCOMResourcePool (+)
    Get-AlertHistory (-) Get-SCOMManagementGroupConnection (+) Remove-SCOMRMSEmulator (+)
    Get-Connector (-) Get-SCOMManagementPack (+) Remove-Tier (-)
    Get-DefaultSetting (-) Get-SCOMManagementServer (+) Resolve-Alert (-)
    Get-Diagnostic (-) Get-SCOMMonitor (+) Set-AlertDestination (-)
    Get-Discovery (-) Get-SCOMNotificationAction (+) Set-DefaultSetting (-)
    Get-Event (-) Get-SCOMNotificationEndpoint (+) Set-MaintenanceWindow (-)
    Get-FailoverManagementServer (-) Get-SCOMNotificationRecipient (+) Set-ManagementServer (-)
    Get-GatewayManagementServer (-) Get-SCOMNotificationSubscription (+) Set-ProxyAgent (-)
    Get-MaintenanceWindow (-) Get-SCOMOverride (+) Set-SCManagementGroupConnection (+)
    Get-ManagementGroupConnection (-) Get-SCOMOverrideResult (+) Set-SCOMAgentlessManagedComputer (+)
    Get-ManagementPack (-) Get-SCOMPendingManagement (+) Set-SCOMAgentManagementServerSetting (+)
    Get-ManagementServer (-) Get-SCOMRecovery (+) Set-SCOMAlert (+)
    Get-Monitor (-) Get-SCOMRelationship (+) Set-SCOMMaintenanceMode (+)
    Get-MonitorHierarchy (-) Get-SCOMRelationshipInstance (+) Set-SCOMManagementGroupConnection (+)
    Get-MonitoringClass (-) Get-SCOMResourcePool (+) Set-SCOMResourcePool (+)
    Get-MonitoringClassProperty (-) Get-SCOMRMSEmulator (+) Set-SCOMRMSEmulator (+)
    Get-MonitoringObject (-) Get-SCOMRule (+) Set-SCOMRunAsProfile (+)
    Get-MonitoringObjectGroup (-) Get-SCOMRunAsAccount (+) Set-SCOMUserRole (+)
    Get-MonitoringObjectPath (-) Get-SCOMRunAsProfile (+) Start-Discovery (-)
    Get-MonitoringObjectProperty (-) Get-SCOMTask (+) Start-SCOMMaintenanceMode (+)
    Get-NotificationAction (-) Get-SCOMTaskResult (+) Start-SCOMTask (+)
    Get-NotificationEndpoint (-) Get-SCOMUserRole (+) Start-Task (-)
    Get-NotificationRecipient (-) Get-SCRelationship (+) Uninstall-Agent (-)
    Get-NotificationSubscription (-) Get-SCRelationshipInstance (+) Uninstall-ManagementPack (-)
    Get-OperationsManagerCommand (-) Get-State (-) Uninstall-SCOMAgent (+)
    Get-Override (-) Get-Task (-)  
    Get-PerformanceCounter (-) Get-TaskResult (-)  
    Get-PerformanceCounterValue (-) Get-Tier (-)  
    Get-PrimaryManagementServer (-) Get-UserRole (-)  
    Get-Recovery (-)    

     

    Most of the changes are changes in the noun naming convention Smile Example: Get-Alert is changed in Get-SCOMAlert.

     

    Have fun!

  • Stefan Stranger's Weblog - Manage your IT Infrastructure

    Lessons learned - The OpsMgr 2007 R2 Universal Connector

    • 3 Comments

    Last week I was asked to help a customer with the configuration of an OpsMgr 2007 R2 connector. Because I had not much hands on experience with the installation and configuration of the OpsMgr 2007 R2 Connectors I installed an configured the Universal Connector in my own test/demo environment.

    And because I learned some new things during this exercise I thought it would be a good idea to share some of my experiences. Warning, this turned out to be become a long blogpost. Stop reading here if you can only read short (twitter) messages Winking smile

    Environment:

    • OpsMgr 2007 R2 CU3
    • OpsMgr 2007 R2 RMS server running on Windows 2008 R2
    • All-In-One RMS with SQL 2008 R2
    • SUSE Linux Enterprise Server (Linux suse10 2.6.16.46-0.12-default)

     

    Downloads:

    I started downloading the free connectors from Microsoft Downloads. This release of the Operations Manager 2007 R2 Connectors includes the following Connectors:

    • Microsoft System Center Operations Manager 2007 R2 Connector for IBM Tivoli Enterprise Console
    • Microsoft System Center Operations Manager 2007 R2 Connector for HP OpenView Operations for Unix
    • Microsoft System Center Operations Manager 2007 R2 Connector for HP OpenView Operations for Windows
    • Microsoft System Center Operations Manager 2007 R2 Connector for BMC Remedy ARS
    • Microsoft System Center Operations Manager 2007 R2 Universal Connector

     

    Documentation:

    If you extract the downloaded SCInterop_R2_RTM.zip file there is a Docs folder with 4 files of documentation you should be READING before installing the Connectors.

    • OM2007_Connectors.doc
    • OM2007_ConnectorsRn.htm
    • OM2007_MP_Connector.doc
    • SCOM2007R2_UniversalConnector_DevelopingAnIntegration.doc

     

    Tools:

    I used the following tools to install and configure the Universal Provider on my SLES10 system:

    • Putty (PuTTY is an SSH and telnet client)
    • WinSCP (WinSCP is an open source free SFTP client, SCP client, FTPS client and FTP client for Windows)
      I used this tool to copy the scx-<build-number>.sles.10.x86.rpm (Interop Core package) installation files from my Windows machine to the SLES10 machine.

     

    You should start reading the Release Notes (OM2007_ConnectorsRn.htm)  thoroughly before you install or upgrade any Operations Manager 2007 R2 Connectors. The next step is reading the Operations Manager 2007 R2 Connectors Deployment Guide (OM2007_Connectors.doc). Here you can check the System Requirements.  In my test/demo environment I’ve installed the Connector Service and Configuration UI on a Windows Server 2008 R2 system without any issues. But be aware this is not supported (yet).

    Other documentation I used to get ready for the installation is this blogpost from our famous Kevin Holman Installing the OpsMgr R2 Universal Connector.

    Operations Manager 2007 Connectors Architecture:

    UniversalConnector

     

    High-Level Installation Steps:

    1. Check Pre-requisites on both systems.
    2. Install Universal Provider on SUSE10 server (always first start with the Provider)
    3. Install Universal Connector Service and Configuration on Windows Server 2008 R2 Server
    4. Configure the Universal Connector

     

    For the detailed installation steps see the Operations Manager 2007 R2 Connectors Deployment Guide but I’ll show some tips and tricks I used to get the Universal Connector installed and configured.

     

    Tips & Tricks:

    Step 1. Check Pre-requisites on both systems.

    How do you check if WSMan is installed on a Windows system?

    You can check if WSMan is installed using the next command from the command prompt:

    winrm identify

    image

    So on my Windows 2008 R2 RMS (where I’ll be installing the Universal Connector Service and UI) WSMan is running.

    How can check if WSMan is running on the remote SLES10 machine?

    Keep in mind that during the install of the SCX agent (Interop core) first  the wsman components (Open Pegasus) will be installed and later the Univeral provider will be installed on top of the SCX agent.

    So it would be “normal” not having wsman installed on the remote SLES10 machine. But in case you want to check anyway. You could check for the cimserver process on the SLES10 machine using the next command in Putty:

    ps –eaf | grep cimserver

    image

    The winrm also has a remote parameter. winrm id –remote:nameofremoteserver.com

    Let’s try to run this from the RMS server.

    image

    It seems we don’t have the correct permissions to do this. Let’s try to use the winrm’s INVOKE verb. More info on the use of the INVOKE verb can be found at Daniele Muscetta’s blogpost about winrm and invoke.

    Run the following command from a Windows machine:

    winrm invoke ExecuteCommand http://schemas.microsoft.com/wbem/wscim/1/cim-schema/2/SCX_OperatingSystem?__cimnamespace=root/scx @{command="ps -eaf";timeout="60"} -username:root -password:Password -auth:basic -r:https://suse10:1270/wsman -skipCACheck -encoding:UTF-8

    image

    There we have it, all running processes on the SLES10 machine using WSMan. Keep in mind this test was run AFTER I had installed the Interop core which also installs Open Pegasus.

     

    Do I need to install the 32-bit version of the Microsoft Visual C++ 2008 Redistributable Package (x86) on a 64-bit Windows 2008 R2 server?

    Yes you need to install the x86 version on a 64-bit OS.

     

    Step 2. Install Universal Provider on SUSE10 server (always first start with the Provider)

    How do I copy the Universal Provider files to my SLES10 server?

    Use WinSCP to connect from your Windows server, where you have the installation files for the connectors to the SLES10 server. Copy the correct OS version files (in my case I copied the files from the Linux_SUSE_10.0_x86_32 folder) to a location (/tmp) on the remote SLES10 server.

    clip_image002

     

    How do I install the Universal Provider on my SLES10 server?

    Use Putty to make a connection to the remote SLES10 machine. Logon with an account which has enough privileges to install the software (I used the root account for the installation of the Universal Provider).

    The first part of the installation is the installation of the the SCX agent first (Interop core) the wsman components (Open Pegasus)

    run the following command in your Putty session: rpm –i /tmp/Linux_SUSE_10.0_x86_32/scx-1.0.4-248.sles.10.x86.rpm

    image

    The second part of the installation is the installation of the Universal Provider.

    Run the next command in your Putty session: Rpm -i MSFTscinteropUnv-6.17000-58.suse.10.x86.rpm

    image

    You can check the result of the installation in the /tmp/scinterop_install.out file using cat or WinSCP if you want.

     

    Step 3. Install Universal Connector Service and Configuration on Windows Server 2008 R2 Server

    Install the Universal Connector and UI using an elevated command prompt.

    Which Features do I need to select during the installation of the Universal Connector and UI?

    Select Entire feature will be installed on local harddrive.

    image

    Remark: You can change the location where the Universal Connector Service is installed if you want.

     

    Which account be used for the Connector Service?

    • On the Connector Service Login page, type in the credentials for the connector service. The connector service will be configured to run under these credentials. This will be used to connect to the SDK on the RMS, and will be used to authenticate to the provider via WSMAN. I used my SDK service account for this, since it already has access to the OpsMgr SDK. Added this account to the local admins group on Server running the Connector Service during the prerequisites stage.
    • Remark: OM_SDK account needs to be member of the Operations Manager Administrators Role.

     

    After the installation of the Universal Connector Service a new database SCInterop is created.

    One step in the configuration is granting the Connector Service Account (SDK account) enough permissions for the SCInterop database. The SDK Config account need db_owner permissions.

    image

    Now it’s time to configure the Universal Connector.

    image

    image

    Which User name do I use for the WS-Man server credentials?

    Enter the next settings:

    • Operations Manager Server (RMS name to connect to the SDK)
    • Universal Provider (Provider server NetBIOS name – NOT FQDN)
    • WS-Man Server credentials (this is an account that has rights to the provider server via WSMan)

     

    image

    Instead of using the root account on the SLES10 server where I installed the Universal Provider I created a scxuser account.

    The scxuser is member of the following groups on the SLES10 server:

    image

    The next step in the Configuration is testing the connection.

    image

    The first time I tested the connection I got an error message.

    image

    Before clicking on Yes to continue the configuration I opened a command prompt to test the connection using the scxuser account.

    Run the following command from the command prompt:
    winrm enumerate http://schemas.microsoft.com/wbem/wscim/1/cim-schema/2/SCX_OperatingSystem?__cimnamespace=root/scx -username:scxuser -password:Password -r:https://suse10:1270/wsman -auth:basic -skipCACheck -encoding:UTF-8

    image

    There seems something wrong with the SSL certificate.

    The Connector requires the use of certificates to validate the authenticity of the server on which the Interop Provider is running. The Connector does not work until the certificate has been transferred and correctly imported to the server on which Connector is running (Windows 2008 R2 RMS Server) from the server on which the Interop Provider (SLES10 Server) is running. During the Interop Provider installation, a self-signed certificate is generated and stored in the Interop Provider installation directory. The Connector Certificate Retrieval and Installation wizard retrieves the certificate and automatically installs it on the server on which the Connector is running. Installing the Connector certificate at installation is optional. However, the Connector certificate must be installed on the server on which the Connector is running before the Connector service is started. If you do not install the Interop Provider certificate, the Connector cannot communicate with the server on which the Interop Provider is running.

    Fixed it by following the next steps:

    1. Copied the scx-host-suse10.pem file to the RMS server

    clip_image001

    2. Runned scxcertconfig -sign scx-host-suse10.pem scx_new.pem on RMS

    clip_image002

    3. Copied the scx_new.pem file to the SUSE10 box (Provider) and renamed it to scx-host-suse10.pem

    clip_image003

    4. Restarted scxadmin –restart (on the SLES10 server)

    image

    5. Tested WSMan connection to provider from RMS.

    In the Universal Connector folder there is a tool called scicert.exe which can be used to test the connection.

    image

    Run the following command from the command prompt:

    scicert suse10 scxuser Password "OpsMgr Universal Connector" test

    image

    Seems to be working ok, right now Smile

    You can also use the winrm enumerate command if you want to:

    winrm enumerate http://schemas.microsoft.com/wbem/wscim/1/cim-schema/2/SCX_OperatingSystem?__cimnamespace=root/scx -username:scxuser -password:Password -r:https://suse10:1270/wsman -auth:basic -skipCACheck -encoding:UTF-8

    image

     

    We now have the Universal Connector installed and configured, now we need to test if OpsMgr Alerts will be forwarded from OpsMgr to the Universal Provider on the SLES10 server.

     

    High-Level Steps to test the Universal Connector.

    1. Add to add a new subscriptions for alerts that you want to send to the connector.
    2. Create a test event rule
    3. Manually emulate an EMS (Enterprise Management System)

     

    Step 1. Add  a new subscription for alerts that you want to send to the connector.

    Go to Administration Pane and select Internal Connectors folder. Select the OpsMgr Universal Connector.

    image

    Double click on the OpsMgr Universal Connector. In the properties of the OpsMgr Universal Connector enter a Subscription Name and optionally a Description.

    image

    Click Next and configure the Groups criteria

    image

    Click Next and configure the Targets.

    image

    Click Next and configure the Alert Criteria

    image

    And in the last screen click OK to save your Subscription.

    image

     

    Step 2. Create a Test Event Rule.

    Just follow the normal steps to create an Event Alert Rule which get’s triggered by eventid 999.

    image

    image

    Every time an event 999 is created an Alert is generated.

    Just use the EventCreate.exe tool to create an Event 999 from the command prompt:

    eventcreate.exe /T ERROR /ID 999 /L APPLICATION /D "Testing Universal Connector"

    Result:

    image

     

    Before we look at what happens on the Remote Universal Provider we need to have some background info on the New Alert Data workflow.

     

    New Alert Data Flow in the Universal Connector:

    1. The Operations Manager alert is forwarded to remote system in either XML or Key=Value Pair(evt) file format (I configured to use XML)
    2. The universal provider on the remote system creates a file (xml or property file) in a specified directory
    3. The custom integration logic picks up file from specified directory and inserts data into the remote system application
    4. The custom integration logic creates a file in a specified directory with specific data to update the Operations Manager alert, i.e. TicketID
    5. The universal provider picks up custom integration file and sends it back to Operations Manager to update the alert
    6. The Operations Manager alert is updated

     

    Step 1 and 2. The Operations Manager alert is forwarded to remote system in either XML or Key=Value Pair(evt) file format and The universal provider on the remote system creates a file (xml or property file) in a specified directory

    We can check if the OpsMgr Alert is forwarded to the remote Universal Provider, which I configured to be in XML format, by opening WinSCP and look in the following folder: /opt/microsoft/scx/UnvEvents/FromOpsMgr

    image

    Let’s create a new Alert by creating a new 999 EventID and check if there will created an XML file in the /opt/microsoft/scx/UnvEvents/FromOpsMgr folder

    image

    image

    Now look at the remote folder and check if we see the xml file on the Universal Provider.

    image

    Let’s check the contents of the xml file.

     

    <?xml version="1.0" encoding="utf-8"?>
    <UNVEvent>
    <AlertId>c16964d1-b01d-4e44-99c9-d892d28fe680</AlertId>
    <ComputerDomain>DEMO</ComputerDomain>
    <ComputerName>OPSMGRR2RMS</ComputerName>
    <Description>Event Description: Testing Universal Connector</Description>
    <EventType>0</EventType>
    <ManagementGroupName>DEMOMG</ManagementGroupName>
    <ManagementPack>Stefan.Test.Universal.Connector</ManagementPack>
    <ManagementServer>opsmgrr2rms</ManagementServer>
    <ModifiedBy>DEMO\OM_Admin</ModifiedBy>
    <MonitoringClassName>Microsoft.Windows.Computer</MonitoringClassName>
    <MonitoringObjectHealthState>Success</MonitoringObjectHealthState>
    <MonitoringObjectInMaintenanceMode>False</MonitoringObjectInMaintenanceMode>
    <MonitoringObjectName>OPSMGRR2RMS.DEMO.STRANGER</MonitoringObjectName>
    <Name>Stefan - Test Universal Connector Event Rule</Name>
    <Priority>Normal</Priority>
    <ProblemId>afcc789a-d227-37a2-79ff-70c6cf469eba</ProblemId>
    <RepeatCount>0</RepeatCount>
    <ResolutionState>255</ResolutionState>
    <RuleName>MomUIGeneratedRule75cfefecc3264771af35f117e44a64ff</RuleName>
    <RuleTarget>Microsoft.Windows.Computer</RuleTarget>
    <Severity>2</Severity>
    <TimeOfLastEvent>2011-08-15T16:48:43.557Z</TimeOfLastEvent>
    <WebConsoleUrl>http://OPSMGRR2RMS:51908/default.aspx?DisplayMode=Pivot&amp;AlertID=c16964d1-b01d-4e44-99c9-d892d28fe680</WebConsoleUrl>
    </UNVEvent>

    Let’s also check if something has changed on the OpsMgr side.

    image

    We don’t see a new Ticked ID or Owner change. The only indication we see is that the History has some info.

    image

     

    Step 3. The custom integration logic picks up file from specified directory and inserts data into the remote system application.

    Now the Universal EMS should pick up the xml file from the /opt/microsoft/scx/UnvEvents/FromOpsMgr and change this data in the EMS (Enterprise Management System). We can do the same manually if we want to test this.

    Steps:

    1. Create a new directory called "<Provider Install Directory>\UnvEvents\<MgmtGrpName>\ using WinSCP on the SLES10 server.

    clip_image001[4]

    clip_image002[4]

    clip_image003[4]

    2. Create a directory called "<Provider Install Directory>\UnvEvents\<MgmtGrpName>\EMS". This directory will contain a evt/xml file with all the necessary information about the alert that is in sync with the connector. If you close the alert in OpsMgr this file will be deleted, acknowledging that the alert was closed.

    clip_image004[4]

    3. You can manipulate the evt/xml file in the EMS directory then drop it into the "<Provider Install Directory>\UnvEvents\<MgmtGrpName>" directory to send updates back to the OpsMgr alert.

    To send an update back to OpsMgr the EventType variable must always be set to 1 (e.g.; EventType=1 or <EventType>1</EventType>).

    Fields that can be update on the OpsMgr alert from the EMS side:

    • EventType
    • OwnerName
    • CustomField1 thru CustomField10
    • ResolutionState


    Let's update the Alert:

    Copy file c16964d1-b01d-4e44-99c9-d892d28fe680.1.xml from /opt/microsoft/scx/UnvEvents/FromOpsMgr to /opt/microsoft/scx/UnvEvents/DEMOMG/EMS folder

     

    cp /opt/microsoft/scx/UnvEvents/FromOpsMgr/c16964d1-b01d-4e44-99c9-d892d28fe680.1.xml /opt/microsoft/scx/UnvEvents/DEMOMG/EMS

    image

     

    Edit c16964d1-b01d-4e44-99c9-d892d28fe680.1.xml

    <?xml version="1.0" encoding="utf-8"?>
    <UNVEvent>
    <AlertId>c16964d1-b01d-4e44-99c9-d892d28fe680</AlertId>
    <ComputerDomain>DEMO</ComputerDomain>
    <ComputerName>OPSMGRR2RMS</ComputerName>
    <Description>Event Description: Testing Universal Connector</Description>
    <EventType>0</EventType>
    <ManagementGroupName>DEMOMG</ManagementGroupName>
    <ManagementPack>Stefan.Test.Universal.Connector</ManagementPack>
    <ManagementServer>opsmgrr2rms</ManagementServer>
    <ModifiedBy>DEMO\OM_Admin</ModifiedBy>
    <MonitoringClassName>Microsoft.Windows.Computer</MonitoringClassName>
    <MonitoringObjectHealthState>Success</MonitoringObjectHealthState>
    <MonitoringObjectInMaintenanceMode>False</MonitoringObjectInMaintenanceMode>
    <MonitoringObjectName>OPSMGRR2RMS.DEMO.STRANGER</MonitoringObjectName>
    <Name>Stefan - Test Universal Connector Event Rule</Name>
    <Priority>Normal</Priority>
    <ProblemId>afcc789a-d227-37a2-79ff-70c6cf469eba</ProblemId>
    <RepeatCount>0</RepeatCount>
    <ResolutionState>0</ResolutionState>
    <RuleName>MomUIGeneratedRule75cfefecc3264771af35f117e44a64ff</RuleName>
    <RuleTarget>Microsoft.Windows.Computer</RuleTarget>
    <Severity>2</Severity>
    <TimeOfLastEvent>2011-08-15T16:48:43.557Z</TimeOfLastEvent>
    <WebConsoleUrl>http://OPSMGRR2RMS:51908/default.aspx?DisplayMode=Pivot&amp;AlertID=c16964d1-b01d-4e44-99c9-d892d28fe680</WebConsoleUrl>
    </UNVEvent>

    <?xml version="1.0" encoding="utf-8"?>
    <UNVEvent>
    <AlertId>c16964d1-b01d-4e44-99c9-d892d28fe680</AlertId>
    <ComputerDomain>DEMO</ComputerDomain>
    <ComputerName>OPSMGRR2RMS</ComputerName>
    <Description>Event Description: Testing Universal Connector</Description>
    <EventType>1</EventType>
    <ManagementGroupName>DEMOMG</ManagementGroupName>
    <ManagementPack>Stefan.Test.Universal.Connector</ManagementPack>
    <ManagementServer>opsmgrr2rms</ManagementServer>
    <ModifiedBy>DEMO\OM_Admin</ModifiedBy>
    <MonitoringClassName>Microsoft.Windows.Computer</MonitoringClassName>
    <MonitoringObjectHealthState>Success</MonitoringObjectHealthState>
    <MonitoringObjectInMaintenanceMode>False</MonitoringObjectInMaintenanceMode>
    <MonitoringObjectName>OPSMGRR2RMS.DEMO.STRANGER</MonitoringObjectName>
    <Name>Stefan - Test Universal Connector Event Rule</Name>
    <Priority>Normal</Priority>
    <ProblemId>afcc789a-d227-37a2-79ff-70c6cf469eba</ProblemId>
    <RepeatCount>0</RepeatCount>
    <ResolutionState>255</ResolutionState>
    <RuleName>MomUIGeneratedRule75cfefecc3264771af35f117e44a64ff</RuleName>
    <RuleTarget>Microsoft.Windows.Computer</RuleTarget>
    <Severity>2</Severity>
    <TimeOfLastEvent>2011-08-16T10:44:19.830Z</TimeOfLastEvent>
    <WebConsoleUrl>http://OPSMGRR2RMS:51908/default.aspx?DisplayMode=Pivot&amp;AlertID=1fbc6201-773f-4680-a120-e6e7e684cd8e</WebConsoleUrl>
    <OwnerName>EMS</OwnerName>
    <CustomField1>Manual Test of EMS</CustomField1>
    </UNVEvent>

    Drop it into the "/opt/microsoft/scx/UnvEvents/DEMOMG

    cp /opt/microsoft/scx/UnvEvents/DEMOMG/EMS/c16964d1-b01d-4e44-99c9-d892d28fe680.1.xml /opt/microsoft/scx/UnvEvents/DEMOMG

     

    image

    Is gone in seconds

    clip_image014

    imageimage

    Works ok :-)

     

    I also created a PowerShell script which retrieves the remote xml file so you can check what has been forwarded from the Universal Connector to the Remote Universal Provider. But I need some more time to improve this script.

    Here is a first example on how I started. If I’ve more time I’ll create a blogpost on how to create a PowerShell EMS tool.

    #use winrm with invoke to retrieve the last xml file from the remote Universal Provider
    [string]$AlertFromUnvConn =  cmd /c 'winrm invoke ExecuteShellCommand http://schemas.microsoft.com/wbem/wscim/1/cim-schema/2/SCX_OperatingSystem?__cimnamespace=root/scx @{command="ls -1t /opt/microsoft/scx/UnvEvents/FromOpsMgr/*.xml | head -1 | xargs cat";timeout="60"} -username:root -password:Password -auth:basic -r:https://suse10:1270/wsman -skipCACheck -encoding:UTF-8'
    $subject = $AlertFromUnvConn

    #Parse the result so we can use this fix the returned XML
    if ($subject -cmatch '(?si)<UNVEvent\b[^>]*>(.*?)</UNVEvent>') {
        $result = $matches[0]
    } else {
        $result = ''
    }

    #Convert result to genuine xml
    [xml]$xml = $result

    #Show Result
    $xml.UNVEvent | format-list

    Result:

    image

     

    Have fun!

  • Stefan Stranger's Weblog - Manage your IT Infrastructure

    OM12 Command Shell vs OpsMgr2007 Command Shell

    • 2 Comments

    Now that System Center Operations Manager 2012 (OM12) Beta available is, it’s time to compare the OM12 Command Shell with the OpsMgr 2007 Command Shell.

     

    Snapin vs Module

    OpsMgr 2007 has a PoweShell Snapin and OM12 uses a PowerShell Module. Modules are a new feature of PowerShell v2 are now widely used in PowerShell. Modules allow you a cleaner way to work with groups of scripts, because they can contain private variables that only those scripts share. You can also refer to a function within a module, which allows you to group commands more logically and to use more common function names without fear of overwriting the names of other functions. More info can be found here.

    How do you know if Snapins or Modules are being used?

    Just open the Operations Manager Shell in OpsMgr 2007 and type: get-pssnapin -registered.

    image

    There we have it, it’s a Snapin

    Now on your OM12 server open the Operations Manager Shell and type: get-module -listavailable

    image

    But wait, there is more. Let’s check if there is also a Snapin.

    image

    Seems we also have installed the “old” OpsMgr 2007 Snapin.

     

    Commands (Verbs & Nouns)

    Let’s start with checking the PowerShell Best-practices for the OM12 Cmdlets and Functions:

    When importing a module or Snapin with the verbose parameter, PowerShell checks if unapproved verbs are being used.

    More information about Cmdlet Verb Names can be found here: http://msdn.microsoft.com/en-us/library/ms714428.aspx

    OpsMgr 2007 had one unapproved verb, the Reject-AgentPending Cmdlet

    You can check this yourself by using the import-module "C:\Program Files\System Center Operations Manager 2007\Microsoft.EnterpriseManagement.OperationsManager.ClientShell.dll" -verbose

    image

    Let’s check OM12 for unapproved verbs:

    image

    No unapproved verbs for the Commands used in OM12 Smile Seems we have followed our own naming principles this time Winking smile

     

    Number of OM12 Commands.

    We can retrieve the number of OM12 commands by using the next commands: (Get-Command -Module OperationsManager).count

    image

    So in OM12 we have 87 Commands to help us manage OM12. We can check the number of Commands for OpsMgr 2007 using PowerShell Remoting from the OM12 Management Server:

    Enter-PSSession –ComputerName OpsMgrRMS.stranger.local -Credential (Get-Credential)
    add-pssnapin "Microsoft.EnterpriseManagement.OperationsManager.Client"
    Set-Location "OperationsManagerMonitoring::"
    New-ManagementGroupConnection -connectionString:opsmgrrms.stranger.local
    Set-Location opsmgrrms.stranger.local
    (get-operationsmanagercommand).count

    image

    So OM12 and OpsMgr 2007 have both 87 Commands.

     

    List of OM12 Commands

    OM12   OpsMgr  

    Name

    CommandType Name CommandType

    Add-SCOMAgentlessManagedComputer
    Approve-SCOMPendingManagement
    Deny-SCOMPendingManagement
    Disable-SCOMAgentProxy
    Disable-SCOMDiscovery
    Disable-SCOMMonitor
    Disable-SCOMNotificationSubscription
    Disable-SCOMRule
    Enable-SCOMAgentProxy
    Enable-SCOMDiscovery
    Enable-SCOMMonitor
    Enable-SCOMNotificationSubscription
    Enable-SCOMRule
    Export-SCManagementPack
    Export-SCOMEffectiveMonitoringConfiguration
    Export-SCOMManagementPack
    Get-SCClass
    Get-SCDiscovery
    Get-SCManagementGroupConnection
    Get-SCManagementPack
    Get-SCOMAccessLicense
    Get-SCOMAgent
    Get-SCOMAgentlessManagedComputer
    Get-SCOMAgentManagementServerSetting
    Get-SCOMAlert
    Get-SCOMAlertHistory
    Get-SCOMClass
    Get-SCOMClassInstance
    Get-SCOMCommand
    Get-SCOMConnector
    Get-SCOMDiagnostic
    Get-SCOMDiscovery
    Get-SCOMEvent
    Get-SCOMGatewayManagementServer
    Get-SCOMGroup
    Get-SCOMMaintenanceMode
    Get-SCOMManagementGroupConnection
    Get-SCOMManagementPack
    Get-SCOMManagementServer
    Get-SCOMMonitor
    Get-SCOMNotificationAction
    Get-SCOMNotificationEndpoint
    Get-SCOMNotificationRecipient
    Get-SCOMNotificationSubscription
    Get-SCOMOverride
    Get-SCOMOverrideResult
    Get-SCOMPendingManagement
    Get-SCOMRecovery
    Get-SCOMRelationship
    Get-SCOMRelationshipInstance
    Get-SCOMResourcePool
    Get-SCOMRMSEmulator
    Get-SCOMRule
    Get-SCOMRunAsAccount
    Get-SCOMRunAsProfile
    Get-SCOMTask
    Get-SCOMTaskResult
    Get-SCOMUserRole
    Get-SCRelationship
    Get-SCRelationshipInstance
    Import-SCManagementPack
    Import-SCOMManagementPack
    Install-SCOMAgent
    New-SCManagementGroupConnection
    New-SCOMManagementGroupConnection
    New-SCOMResourcePool
    Remove-SCManagementGroupConnection
    Remove-SCManagementPack
    Remove-SCOMAgentlessManagedComputer
    Remove-SCOMDisabledClassInstance
    Remove-SCOMManagementGroupConnection
    Remove-SCOMManagementPack
    Remove-SCOMResourcePool
    Remove-SCOMRMSEmulator
    Set-SCManagementGroupConnection
    Set-SCOMAgentlessManagedComputer
    Set-SCOMAgentManagementServerSetting
    Set-SCOMAlert
    Set-SCOMMaintenanceMode
    Set-SCOMManagementGroupConnection
    Set-SCOMResourcePool
    Set-SCOMRMSEmulator
    Set-SCOMRunAsProfile
    Set-SCOMUserRole
    Start-SCOMMaintenanceMode
    Start-SCOMTask
    Uninstall-SCOMAgent

    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Alias
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Alias
    Cmdlet
    Function
    Cmdlet
    Cmdlet
    Alias
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Alias
    Alias
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Alias
    Alias

    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Alias
    Cmdlet
    Cmdlet
    Alias
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Alias
    Alias
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Alias
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet

    Add-ConnectorToTier
    Add-RemotelyManagedComputer
    Add-RemotelyManagedDevice
    Add-UserToUserRole
    Approve-AgentPendingAction
    Disable-NotificationSubscription
    Disable-Rule
    Enable-NotificationSubscription
    Enable-Rule
    Export-ManagementPack
    Get-Agent
    Get-AgentPendingAction
    Get-Alert
    Get-AlertDestination
    Get-AlertHistory
    Get-Connector
    Get-DefaultSetting
    Get-Diagnostic
    Get-Discovery
    Get-Event
    Get-FailoverManagementServer
    Get-GatewayManagementServer
    Get-MaintenanceWindow
    Get-ManagementGroupConnection
    Get-ManagementPack
    Get-ManagementServer
    Get-Monitor
    Get-MonitorHierarchy
    Get-MonitoringClass
    Get-MonitoringClassProperty
    Get-MonitoringObject
    Get-MonitoringObjectGroup
    Get-MonitoringObjectPath
    Get-MonitoringObjectProperty
    Get-NotificationAction
    Get-NotificationEndpoint
    Get-NotificationRecipient
    Get-NotificationSubscription
    Get-OperationsManagerCommand
    Get-Override
    Get-PerformanceCounter
    Get-PerformanceCounterValue
    Get-PrimaryManagementServer
    Get-Recovery
    Get-RelationshipClass
    Get-RelationshipObject
    Get-RemotelyManagedComputer
    Get-RemotelyManagedDevice
    Get-ResultantCategoryOverride
    Get-ResultantRuleOverride
    Get-ResultantUnitMonitorOverride
    Get-RootManagementServer
    Get-Rule
    Get-RunAsAccount
    Get-State
    Get-Task
    Get-TaskResult
    Get-Tier
    Get-UserRole
    Install-Agent
    Install-AgentByName
    Install-ManagementPack
    New-CustomMonitoringObject
    New-DeviceDiscoveryConfiguration
    New-LdapQueryDiscoveryCriteria
    New-MaintenanceWindow
    New-ManagementGroupConnection
    New-MonitoringPropertyValuePair
    New-Tier
    New-WindowsDiscoveryConfiguration
    Reject-AgentPendingAction
    Remove-ConnectorFromTier
    Remove-DisabledMonitoringObject
    Remove-ManagementGroupConnection
    Remove-RemotelyManagedComputer
    Remove-RemotelyManagedDevice
    Remove-Tier
    Resolve-Alert
    Set-AlertDestination
    Set-DefaultSetting
    Set-MaintenanceWindow
    Set-ManagementServer
    Set-ProxyAgent
    Start-Discovery
    Start-Task
    Uninstall-Agent
    Uninstall-ManagementPack

    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet
    Cmdlet

    Some of the Commands I highlighted are some of the aliases being used in OM12.

    You can get more information on Aliases by using the Get-Command -module operationsmanager –CommandType Alias

    image

    I guess these Aliases are created to give the OM12 Commands a consistent SCOM* Naming Convention.

    And for the current OM12 Commands we also see we have created a Function Get-SCOMCommand. So how is that Get-SCOMCommand Function created?

    First we are going into the Function drive.

    CD Function:

    Next we are using the Get-Content Cmdlet to look into the Get-SCOMCommand function.

    Get-Content Get-SCOMCommand

    image

    Ok, we just created a function which uses the Get-Command –Module OperationsManager to list all SCOM Commands Smile

     

    This is it for now, but I’ll try to post more about the new OM12 Commands.

  • Stefan Stranger's Weblog - Manage your IT Infrastructure

    Extract Exchange 2010 Management Pack files from MSI file

    • 2 Comments

    Today I wanted to have a look at the Exchange 2010 Management Pack files, but I did not had access to an OpsMgr 2007 environment and only had my laptop with Windows 7 running with me. So I started to download the Exchange 2010 MP from the Microsoft PinPoint Website.

    After the download had finished I tried to install the Exchange2010ManagementPackForOpsMgr2007-EN-x64.msi file but it failed with the next error.

    image

     

    Although you could argue that Windows 7 is a higher OS than Windows Server 2003 I opened Orca to have a look at the MSI Installer. But than I remembered you can easily extract files from a MSI using the next commands:


    msiexec /a Exchange2010ManagementPackForOpsMgr2007-EN-x64.msi /qb TARGETDIR="c:\temp\exchange2010"

     

    image

     

    And there they where, the MP files I was looking for Smile

    image

     

    Have fun!

  • Stefan Stranger's Weblog - Manage your IT Infrastructure

    Who put the RMS in Maintenance Mode? (2nd update)

    • 2 Comments

    I was investigating an issue with OpsMgr Agents who where stuck in Maintenance Mode. A big help was this article from David Dixon.

    We managed to solve the issue but we also wanted to know what caused the issue and I investigated if the RMS HealthService was put in Maintenance Mode accidentally. By the way, it is not a good thing to put the RMS in Maintenance Mode!

    Update 2: I got an email from one of my co-workers Marek Tyszkiewicz telling me he made an enhancement to my SQL query to find out if the RMS HealthService was put in Maintenance Mode:

    -- Find if RMS is put in MM
    -- Author: Stefan Stranger
    -- Version 0.3
    -- Remark: Added (NOLOCK) to query. Thanks to Jeremy Pavleck.
    -- Remark: No need to specify  RMS server name. Thanks to Marek Tyszkiewicz
    -- Date: 20-04-2011
    USE OperationsManagerDW
    SELECT ManagedEntity.DisplayName, MaintenanceModeHistory.*
    FROM ManagedEntity WITH (NOLOCK)
    INNER JOIN MaintenanceMode ON ManagedEntity.ManagedEntityRowId = MaintenanceMode.ManagedEntityRowId
    INNER JOIN MaintenanceModeHistory ON MaintenanceMode.MaintenanceModeRowId = MaintenanceModeHistory.MaintenanceModeRowId
    WHERE (ManagedEntity.DisplayName in (
    SELECT DISTINCT METarget.DisplayName
    FROM vManagedEntity MESource
    INNER JOIN vRelationship R ON R.SourceManagedEntityRowId = MESource.ManagedEntityRowId
    INNER JOIN ManagedEntity METarget ON R.TargetManagedEntityRowId = METarget.ManagedEntityRowId
    WHERE MESource.FullName  = 'Microsoft.SystemCenter.RootManagementServerComputersGroup'
    ))

    Have fun pointing your finger ;-)

  • Stefan Stranger's Weblog - Manage your IT Infrastructure

    Finding Multihomed OpsMgr agents with PowerShell

    • 0 Comments

    This week I got some questions about Multihoming agents. As you know, a multihomed architecture is based on the concept of an agent reporting to two (or more) management groups. But first I wanted to know how I could see if an agent was a multihomed agent and I used PowerShell to look into the registry of an agent for the ManagementGroup information.

     

    dir "HKLM:\SOFTWARE\Microsoft\Microsoft Operations Manager\3.0\Agent Management Groups\" `
    | Format-Table @{Label="ManagementGroup";Expression={$_.PSChildName}} –aut

     

    Result:

    image

    Is this case I used PowerShell Remoting to connect to another Agent in my OpsMgr demo environment to collect the Management Group information.

    As you see I don’t have a multihomed agent in my demo environmentSmile

  • Stefan Stranger's Weblog - Manage your IT Infrastructure

    AddToDistList Tool - Adding a computer to the Distribution list on a RunAs Account

    • 5 Comments

    Some weeks ago I saw a question about how to use PowerShell for the ApproveCredentialForDistribution method. This Method Approves a secure credential for distribution to a list of MonitoringObject objects or PartialMonitoringObject objects. Calling this method adds the specified list to the already existing approved list in the system.

    You use this method when you add a computer to the Run As Account.

    clip_image002[4]

    clip_image002

     

    But what if you want to add not one but much more Computers to a Distribution List? In the OpsMgr Console you need to select each computer one-by-one and add the computer to the list. Would not it be cool if we could use PowerShell or some commandtool to create a script to do it automatically for us?

    On the Technet System Center Forum website there is also a discussion about this topic. So I looked at the method on MSDN and tried to get this working in PowerShell. But till now I’ve not been able to get this working in PowerShell Sad smile So I created a Console App in Visual Studio 2010 which seems to work ok. I’ll add the source code so you can have a look how I  created the Console App. I also used nConsoler, which helped with the parsing of arguments in the console application. And finally I used ILMerge to merge the nConsoler dll in a single .NET assembly.

    Program.cs:

    using System;
    using System.Text;
    using Microsoft.EnterpriseManagement;
    using Microsoft.EnterpriseManagement.Configuration;
    using Microsoft.EnterpriseManagement.ConnectorFramework;
    using Microsoft.EnterpriseManagement.Monitoring;
    using Microsoft.EnterpriseManagement.Monitoring.Security;
    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    using System.Diagnostics;
    using System.Xml;
    using System.Security;
    using Microsoft.EnterpriseManagement.Administration;
    using NConsoler; //http://nconsoler.csharpus.com/
    
    namespace OpsMgrApproveCredentialForDistribution
    {
        class Program
        {
            static void Main(string[] args)
            {
                //NConsoler
                Consolery.Run(typeof(Program), args);
            }
    
            [Action]
            public static void DoWork(
                [Required(Description="Enter RMS Server name")]
                string RMS,
                [Required(Description="Enter RunAs Account Name")]
                string RunAsAccount,
                [Required(Description = "Enter FQDN OpsMgr Agent\n" +
                    "\nExample: AddToDistList.exe opsmgrrms.contoso.com om_sql_mon opsmgragent.contoso.com" +
                    "\nAdding a computer to the Distribution list on a RunAs Account application for OpsMgr 2007" +
                    "\nemailname@hotmail.com\n" +
                    "\nProvided 'AS IS' without warranty of any kind")]
                string OpsMgrAgent)
            {            
                Console.WriteLine("OpsMgrApproveCredentialForDistribution - Version 1.3 - Compiled March 5, 2011");
                Console.WriteLine("http://blogs.technet.com/stefan_stranger");
    
    
                    // Connect to the sdk service on the RMS
                    //ManagementGroup localManagementGroup = new ManagementGroup(strRMS);
                    ManagementGroup localManagementGroup = ConnectMG(RMS);
                    if (localManagementGroup == null)
                    {
                        Console.WriteLine("Failed to connect to Root Management Server " + RMS);
    
                    }
                    else
                    {
                        MonitoringSecureDataCriteria runAsAccountCriteria;
                        ReadOnlyCollection<MonitoringSecureData> runAsAccounts;
    
                        Console.WriteLine("RunAs Account Username:" + RunAsAccount);
    
                        runAsAccountCriteria = new MonitoringSecureDataCriteria("UserName LIKE " + "'" + RunAsAccount + "'");
                        runAsAccounts = localManagementGroup.GetMonitoringSecureData(runAsAccountCriteria);
    
                        if (runAsAccounts.Count == 0)
                            throw new InvalidOperationException("Error! RunAs Account not found: " + RunAsAccount);
    
                        MonitoringSecureData account = runAsAccounts[0];
                        List<MonitoringObject> list = new List<MonitoringObject>();
    
                        // Fully qualified name of the agent-managed computer.
                        ManagementGroupAdministration admin = localManagementGroup.GetAdministration();
    
                        string query = "Name = '" + OpsMgrAgent + "'";
                        AgentManagedComputerCriteria agentCriteria =
                            new AgentManagedComputerCriteria(query);
                        ReadOnlyCollection<AgentManagedComputer> agents =
                            admin.GetAgentManagedComputers(agentCriteria);
                        if (agents.Count != 1)
                            throw new InvalidOperationException("Error! OpsMgr Agent not found: " + OpsMgrAgent);
    
    
                        //Add OpsMgr Agent to list
                        list.Add(agents[0].HostedHealthService);
                        localManagementGroup.ApproveCredentialForDistribution((ISecuredData)account, list);
                        Console.WriteLine("OpsMgr Agent " + OpsMgrAgent + " added to distribution list");
                }
            
    
       }
    
            private static ManagementGroup ConnectMG()
            {
                throw new NotImplementedException();
            }
    
            //Connect to SDK Service on Root Management Server
            private static ManagementGroup ConnectMG(String RMS)
            {
                Console.WriteLine("Connect to Root Management Server:" + RMS);
                try
                {
                    ManagementGroupConnectionSettings connectionSettings = new ManagementGroupConnectionSettings(RMS);
                    ManagementGroup localManagementGroup = ManagementGroup.Connect(connectionSettings);
                    if (!localManagementGroup.IsConnected)
                    {
                        throw new InvalidOperationException("Not connected to an SDK Service.");
                    }
                    Console.WriteLine("Connected to Management Group {0}", localManagementGroup.Name);
                    return localManagementGroup;
                }
                catch (Exception exception)
                {
                    Console.WriteLine("\nConnection failed. " + exception.Message);
                    if (exception.InnerException != null)
                    {
                        Console.WriteLine(exception.InnerException.Message);
                        return null;                    
                    }
                }
                    return null;
                    
            }
            
        }
    }
     
    Ok let’s have a look how it works. 
    Scenario:
    We will be adding the OpsMgr Agent OpsMgrDC01.stranger.local to the SQL MP Monitoring Account Run As Account. (yes this is just an example there is no SQL running on my Domain Controller) Winking smile
    Current Config SQL MP Monitoring Run As Account:
    imageimage
     
    Step 1: Install AddToDistList console application on machine where OpsConsole is installed.
    Just copy the AddToDistList.exe to a folder of your choice.
    image
     
    Step 2. Open the AddToDistList.exe from command prompt.
    image

    As you see it needs 3 parameters:

    • RMS Name
    • RunAs Account Name (domain account name)
    • FQDN OpsMgr Agent

     

    When we want to add the OpsMgrDC01.stranger.local OpsMgr Agent to the SQL MP Monitoring Account Run As Account we need to run the following:

    AddToDistList.exe opsmgrrms.stranger.local om_sql_mon opsmgrdc01.stranger.local

    image

    Let’s check if the opsmgrdc01 agent is added to the distribution list.

    Yes! It worked Smile

    image

     

    Now you could create a script that pull’s the names of the computers that need to be added to the Distribution List from a text file and call’s the AddToDistList console application.

    Download AddToDistList.exe

    Download SourceCode

    Disclamer:

    This is provided as a sample, no support is implied. Provided 'AS IS' without warranty of any kind. I wrote it for me initially.I'm not a developer, and don't profess to be either; just to set your expectations Smile

    Tested on OpsMgr 2007 R2.

  • Stefan Stranger's Weblog - Manage your IT Infrastructure

    What is the impact of the OpsMgr Web Console on the RMS?

    • 1 Comments

    This week I had a conversation with a customer who wanted to offer their admins OpsMgr Web Consoles instead of the “normal” fat-client OpsMgr Consoles. Most customers think that the Web Console would have less impact on the RSM as the “normal” fat-client.

    But when we look in the Operations Manager 2007 Performance and Scalability Guide and look at what impacts the performance of the RMS we read:

    Factors that influence the load on the root management server include:

    • Number of Agents in the management group. Because the root management server must compute the configuration for all agents in the management group, increasing the number of agents increases the amount of memory required by the root management server, regardless of how much operational data the agents send, such as alerts, events, performance data, etc.
    • Rate of instance space changes. The instance space is the data that Operations Manager maintains to describe all of the monitored computers, services, and applications in the management group. When this data changes frequently, additional resources are needed by the root management server to compute configuration updates for the affected agents. The rate of instance space changes increases as you import additional Management Packs into your management group. Adding new agents to the management group also temporarily increases the rate of instance space changes. Seeing a consistently high rate of instance space changes might indicate that the Management Packs you imported need tuning to send discovery data less frequently.
    • Number of Operations Consoles and other SDK clients running simultaneously. Examples of other SDK clients include the Web console and many third-party tools that interface with Operations Manager. Because the SDK Service is hosted on the root management server, each additional connection uses memory and CPU.

    And because the Web Console is a SDK Client just like the “normal” OpsMgr Console, you could conclude that the Web Console has the same impact on the RMS as the “normal” OpsMgr Console. But what happens when you use the Web Console in OpsMgr 2007 R2? The R2 Web Console opens the connection, then caches the connection instance in the Session on the server and reuses for all subsequent requests. The connection is not closed explicitly. As said earlier the Web Console uses the same API calls as the “normal” OpsMgr Console.

    The major difference between the Web Console and the OpsMgr Console is the OpsMgr Console local cache. So you could say the Web Console has more impact on the RMS just because it queries the RMS each time that data is needed, versus the OpsMgr Console looking in the local cache first.

    You can configure the Web Console settings via the web.config file. My colleague Micheal Pearson has written a blogarticle about which settings can be configured. You could limit the rows in your Alert Views or State views, but this is done on the Web Server hosting the OpsMgr Web Console. Still all data is queried via the SDK on the databases. The web.config settings controls the rendering, that is how much data is transferred from the web server to the client.

    Hope this clarifies the difference between the Web Console and OpsMgr Console and their impact on the RMS. I want to thank Michael Pearson and Alexander Netrebchenko for helping with topic.

  • Stefan Stranger's Weblog - Manage your IT Infrastructure

    2011 Scripting Games

    • 0 Comments

    2011 Scripting Games

     

     

     

     

     

     

     

    Grab this badge here!

    Last year I participated for the first time in the Scripting Games and it was a great experience because I was the lucky winner of PowerShell ASP software from n/Software. But now it’s your chance to participate in the 2011 Scripting Games.

    The 2011 Scripting Games begin on April 4, 2011 and run through April 15, 2011. What is the Scripting Games, you may ask? Well simply put, the Scripting Games are the premier learning event of the year for IT Pro’s and others who wish to master Windows PowerShell. Comprising 10 events, a registered contestant has seven days to create a solution to a scenario driven problem and post their code to a MVP maintained script repository for evaluation by a panel of internationally recognized judges. Daily leaderboards and prize drawings help to maintain the suspense throughout the two-week international event.

    During the 2011 Scripting Games hundreds of contestants will submit thousands of scripts that will be reviewed by dozens of judges. Hundreds of thousands of spectators from all around the world will view the games themselves. Last year, participants from more than 100 countries participated in the Scripting Games. With an emphasis on real world scripting scenarios and problems, the scripts will be of immediate value to both the participants and to the spectators.

    Preparation for the 2011 Scripting Games is already underway, with a learning guide, step-by-step tutorials, videos and other resources being generated on a daily basis. The 2011 Scripting Games all in one page is the portal for the games themselves. The 2010 Scripting Games all in one page is still available, as are the events from the 2009 Scripting Games.

  • Stefan Stranger's Weblog - Manage your IT Infrastructure

    Pulling OpsMgr Company Knowledge from Management Pack and send it to email

    • 2 Comments

    Some weeks ago I got a question from Marnix Wolf asking if it’s possible to retrieve Company Knowledge for a monitor or rule and sent that as email. And after an evening playing around with PowerShell I created a PowerShell script that could do exactly that.

     

    Pre-requisites:

    • OpsMgr 2007 (R2)
    • PowerShell version 2.0 (I only tested the script in PowerShell version 2.0)
    • Company Knowledge stored in one Management Pack

     

    Background info:

    I hope you know you can add your own Company Knowledge for a rule or monitor.  Administrators can add their own knowledge to rules and monitors to expand the troubleshooting information and provide company-specific information for operators, which is known as company knowledge. Administrators can use company knowledge to document any overrides implemented for a monitor or rule, along with the explanation for the customization and any other information that might be useful.

    Operations Manager stores company knowledge in a management pack. Sealed management packs cannot be modified, so Operations Manager saves customizations such as company knowledge in a custom management pack. By default, Operations Manager saves all customizations to the Default Management Pack. As a best practice, you should instead create a separate management pack for each sealed management pack you want to customize. More info about adding Company Knowledge can be found here. For the pre-requisites you can take a look at this blogpost on the MOMTeam blogsite.

     

    Steps:

    1. Let’s first create a Management Pack to store the Company Knowledge.
      image

      I’ve created a Management Pack called Stefan – Company Knowledge Test MP.
    2. The next steps is to create Company Knowledge for some monitors and rules.
    1. Open in the OpsMgr Console a Monitor for which we want to add Company Knowledge. I choose the AD Domain Availability Health Rollup Monitor because there is an Alert for this monitor in my demo environment.
      image
    2. Open the Company Knowledge Tab and select Edit.
      image
    3. Word will be launched (in my case it’s Word 2010) and insert the Company Knowledge you want to Edit.
      image
    4. Once this is done, click File/Save. Do NOT close out the Word document. If you do you will lose any information that you had saved.
    5. image 
    6. Press the Save button  to save Company Knowledge and make sure you save it in the correct Management Pack!
    7. Let’s do the same for a rule. I selected the AD Agent Assignment: Rule Failure rule.
    8. Follow steps 1 to 7 again to add your Company Knowledge for this rule.
      image
    9. And again save the Company Knowledge in the same Management Pack.

     

    Now we saved the Company Knowledge for the monitor and rule we can extract this info from the Management Pack. It’s also somewhere in the database but extracting it from the Management Pack is the easiest way IMO.

     

    These are the high-level steps that need to be executed in the PowerShell script:

    1. Find Monitor or Rule for Alert.
    2. Export Management where Company Knowledge is saved.
    3. Parse Company Knowledge for Monitor from exported XML MP.
    4. Email Company Knowledge

     

    Step 1. Find Monitor or Rule for Alert.

    #Error Handling
    #This is because when there is no monitor found in the FindMonitorForAlert Function
    #the script needs to continue.
    $ErrorActionPreference="SilentlyContinue"
    $Error.psbase.clear()

           
    Function Initialize
    {
         ## Check for OpsMgr shell
        if ((Get-PSSnapin | Where-Object {$_.Name -eq 'Microsoft.EnterpriseManagement.OperationsManager.Client'}) -eq $null)
        {
            Write-Host "Load OpsMgr Snapin if not loaded" -foregroundcolor red
            LoadSnapin("localhost")
        }
    }
         
    Function LoadSnapin($RMS)
    {
        add-pssnapin "Microsoft.EnterpriseManagement.OperationsManager.Client";
        set-location "OperationsManagerMonitoring::";
        new-managementGroupConnection -ConnectionString:$RMS;
        set-location $RMS;
    }
         
         
    Function FindMonitorOrRuleForAlert($AlertName)
    {
        #Find an alert with resolution state new
        $alert = get-alert | where {$_.Name -eq "$AlertName"}
       
        #Check if Alert is available
        if ($alert)
        {   
            #Find monitor for Alert.
            $monitorname = (get-monitor $alert.monitoringruleid).Name

            #Check if Monitor is found
            if ($monitorname)
            {
                Write-Host "Monitor Found"
                return $monitorname
            }
            else
            {
                #Call FindRuleForAlert
                FindRuleForAlert $AlertName           
            }
        }
        else
            {
            Write-Host "No Alert found"
            }
    }
       
    Function FindRuleForAlert($AlertName)
    {
        $alert = get-alert | where {$_.Name -eq "$AlertName"}
               
        #Find rule for Alert.
        $rulename = (get-rule $alert.monitoringruleid).Name
       
        Write-Host "Rule Found"       
        return $rulename
    }
       
       
    #Main
     
    Initialize
     
    FindMonitorOrRuleForAlert "Data Access Service - Windows Service"
     
    FindMonitorOrRuleForAlert "Root Management Server Unavailable." 

    When we run the above PowerShell script we find the Monitor or Rule name for the  alerts “Data Access Service – Windows Service” and “Root Manager Server Unavailable.

    image

     

    image

    We know have a way to find the Monitor or Rule name for an alert.

    Step 2. Export Management where Company Knowledge is saved.

    <#
        In this part of the script we are going to export the Management Packs
        and save it in the User's temp folder
    #>


    Function Initialize
    {
         ## Check for OpsMgr shell
        if ((Get-PSSnapin | Where-Object {$_.Name -eq 'Microsoft.EnterpriseManagement.OperationsManager.Client'}) -eq $null)
        {
            Write-Host "Load OpsMgr Snapin if not loaded" -foregroundcolor red
            LoadSnapin("localhost")
        }
    }
         
    Function LoadSnapin($RMS)
    {
        add-pssnapin "Microsoft.EnterpriseManagement.OperationsManager.Client";
        set-location "OperationsManagerMonitoring::";
        new-managementGroupConnection -ConnectionString:$RMS;
        set-location $RMS;
    }


    Function ExportMP($MPname, $mpexportfolder)
        {
            #Get Management where Company Knowledge is saved. Must be know in advance.
            get-managementpack | where {$_.Name -eq $MPName} | export-managementpack -path $mpexportfolder
            Write-Host "MP exported to xml"
        }


    #Main

    Initialize

    ExportMP -MPname "Stefan.Company.Knowledge.Test.MP" -mpexportfolder ($env:TEMP)

    Result:

    image

     

    We now exported the Management Pack where we saved the Company Knowledge to the users temp directory.

    Step 3. Parse Company Knowledge for Monitor from exported XML MP.

    <#
        In this part of the script we are parse the Company Knowledge
        for the Monitor or Rule
    #>

    #Variables
    $monitorname = "Microsoft.Windows.Server.AD.Domain.AvailRollupMonitor"


    Function Initialize
    {
         ## Check for OpsMgr shell
        if ((Get-PSSnapin | Where-Object {$_.Name -eq 'Microsoft.EnterpriseManagement.OperationsManager.Client'}) -eq $null)
        {
            Write-Host "Load OpsMgr Snapin if not loaded" -foregroundcolor red
            LoadSnapin("localhost")
        }
    }
         
    Function LoadSnapin($RMS)
    {
        add-pssnapin "Microsoft.EnterpriseManagement.OperationsManager.Client";
        set-location "OperationsManagerMonitoring::";
        new-managementGroupConnection -ConnectionString:$RMS;
        set-location $RMS;
    }

    Function ParseCK($monitor,$mpexportfolder,$MPName)
    {
        $xml =  [xml](Get-Content $mpexportfolder"\"$MPname".xml")
             
        #MonitorName
        $ElementID = "'"+ "$Monitor" + "'"
        $KnowledgeArticle = [xml](Select-Xml -xml $xml -xpath "//KnowledgeArticle[contains(@ElementID, $ElementID)]")
        $myarray = $KnowledgeArticle.MamlContent.section
        $myarray | Format-Table @{Label="Title";Expression={$_.title}}, @{Label="Text";Expression={$_.para}} -aut
        Write-Host "finished"
    }
         
    #Main
         
    Initialize

    ParseCK -monitor $monitorname -mpexportfolder ($env:TEMP) -MPName "Stefan.Company.Knowledge.Test.MP"

    Result:

    image

    Or for the Rule:

    image

     

    Step 4. Email Company Knowledge

    In PowerShell 2.0 there is a new cmdlet Send-MailMessage, but I’m going to use the Net.Mail.MailMessage .Net class because my smtp server needs authentication.

    <#
        In this part of the script we are emailing the Company Knowledge
    #>


    #Body
    $body = @"
        <h1>Knowledge Article</h1>

        <h2>Summary</h2>

        <h2>Configuration</h2>

        <h2>Causes</h2>

        <h2>Resolutions</h2>

        <h2>Additional Information</h2>

        <h2>External Knowledge Sources</h2>
    "@


    # Create mail and set priority
    $mail = new-object Net.Mail.MailMessage
    $mail.Priority = [System.Net.Mail.MailPriority]::High

    # Create from, to, and bcc
    $mail.From  = opsmgr@stranger.local
    $mail.To.Add("username@hotmail.com")
    $mail.CC.Add("username@microsoft.com")
    $mail.BCC.Add(username@stranger.local)

    # Create the message
    $mail.Subject = "OpsMgr email with Company Knowledge" + " (" + [System.DateTime]::Now.ToString("yyyy-MM-dd HH:mm") + ")"
    $mail.Body = $body
    $mail.IsBodyHtml = $true

    # Set SMTP Server and create SMTP Client
    $smtp = new-object Net.Mail.SmtpClient
    $smtp.Host = "mail.stranger.local"
    $smtp.Port = "25"
    $smtp.EnableSsl = $false
    $smtp.Credentials = New-Object System.Net.NetworkCredential(stefan@stranger.local, P@ssw0rd);

    # Send message
    try {
       $smtp.Send($mail)
    }
    catch {
      "Exception caught: {0}" -f $Error[0]
    }

    Result:

    image

     

    Ok now we only have to put all the separate parts together Winking smile

     

    <#
        Pulling OpsMgr Company Knowledge from Management Pack and send it to email.
        This script will find the monitor or rule for a selected alert and
        pull the Company Knowledge for this monitor or rule from the exported Management Pack.
        Tested on:
        - OpsMgr 2007 R2
        - PowerShell version 2.0
        Remark: All the Company Knowledge should be saved in ONE Management Pack
        Author: Stefan Stranger
        Date: 17-02-2011
    #>

    param($AlertName=(Read-Host "Please Enter Alert Name"),$emailto=(Read-Host "Please Enter email address"))

     

    #Variables:
    $global:mpname = ""
    $global:rmsname = "opsmgrrms.stranger.local"
    $global:mpname = "Stefan.Company.Knowledge.Test.MP"
    $currentpath = pwd

    #Error Handling
    #This is because when there is no monitor found in the FindMonitorForAlert Function
    #the script needs to continue.
    $ErrorActionPreference="SilentlyContinue"
    $Error.psbase.clear()

           
    Function Initialize
    {
         ## Check for OpsMgr shell
        if ((Get-PSSnapin | Where-Object {$_.Name -eq 'Microsoft.EnterpriseManagement.OperationsManager.Client'}) -eq $null)
        {
            Write-Host "Load OpsMgr Snapin if not loaded" -foregroundcolor red
            LoadSnapin("$rmsname")
        }
    }
         
    Function LoadSnapin($rmsname)
    {
        add-pssnapin "Microsoft.EnterpriseManagement.OperationsManager.Client";
        set-location "OperationsManagerMonitoring::";
        new-managementGroupConnection -ConnectionString:$rmsname;
        set-location $rmsname;
    }

    Function FindRuleForAlert($AlertName)
    {
        $alert = get-alert | where {$_.Name -like "$AlertName"}
       
        $monitoringruleid = ($alert | select MonitoringRuleID -first 1).MonitoringRuleId.Guid
               
        #Find rule for Alert.
        $rulename = (get-rule $monitoringruleid).Name
       
        Write-Host "Rule Found"       
        return $global:monitororrulename = $rulename
    }
         
         
    Function FindMonitorOrRuleForAlert($AlertName)
    {
        #Find an alert with resolution state new
        $alert = get-alert | where {$_.Name -like "$AlertName"}
       
        #Check if Alert is available
        if ($alert)
        {   
           
            $monitoringruleid = ($alert | select MonitoringRuleID -first 1).MonitoringRuleId.Guid
            #Find monitor for Alert.
            $monitorname = (get-monitor $monitoringruleid).Name

            #Check if Monitor is found
            if ($monitorname)
            {
                Write-Host "Monitor Found"
                return $global:monitororrulename = $monitorname
            }
            else
            {
                #Call FindRuleForAlert
                FindRuleForAlert $AlertName           
            }
        }
        else
            {
            Write-Host "No Alert found"
            break
            }
    }
       

       
       
     
    #Step 2. Export Management where Company Knowledge is saved.
    <#
        In this part of the script we are going to export the Management Packs
        and save it in the User's temp folder
    #>


    Function ExportMP($MPname, $mpexportfolder)
    {
        #Get Management where Company Knowledge is saved. Must be know in advance.
        get-managementpack | where {$_.Name -eq $MPName} | export-managementpack -path $mpexportfolder
        Write-Host "MP exported to xml"
    }


    #Step 3. Parse Company Knowledge for Monitor from exported XML MP.
    <#
        In this part of the script we are parse the Company Knowledge
        for the Monitor or Rule
    #>

    Function ParseCK($monitororrulename,$mpexportfolder,$MPName)
    {
        $xml =  [xml](Get-Content $mpexportfolder"\"$MPname".xml")
             
        $ElementID = "'"+ "$monitororrulename" + "'"
        $KnowledgeArticle = [xml](Select-Xml -xml $xml -xpath "//KnowledgeArticle[contains(@ElementID, $ElementID)]")
        $global:myarray = $KnowledgeArticle.MamlContent.section
        #$myarray | Format-Table @{Label="Title";Expression={$_.title}}, @{Label="Text";Expression={$_.para}} -aut
        Write-Host "Parsed Company Knowledge"
    }

    #Step 4. Email Company Knowledge
    <#
        In this part of the script we are emailing the Company Knowledge
    #>

    $Summary = ($myarray | where {$_.Title -eq "Summary"}).para
    $Configuration = ($myarray | where {$_.Title -eq "Configuration"}).para
    $Causes = ($myarray | where {$_.Title -eq "Causes"}).para
    $Resolutions = ($myarray | where {$_.Title -eq "Resolutions"}).para
    $Additional = ($myarray | where {$_.Title -eq "Additional"}).para
    $External = ($myarray | where {$_.Title -eq "External"}).para


    #Body
    $body = @"
        <h1>Knowledge Article</h1>

        <h2>Summary</h2>
        <p>$Summary</P>
        <h2>Configuration</h2>
        <p>$Configuration</P>
        <h2>Causes</h2>
        <p>$Causes</P>
        <h2>Resolutions</h2>
        <p>$Resolutions</P>
        <h2>Additional Information</h2>
        <p></P>
        <h2>External Knowledge Sources</h2>
        <p>$External</P>
    "@

    Function EmailCK($emailto)
    {

        # Create mail and set priority
        $mail = new-object Net.Mail.MailMessage
        $mail.Priority = [System.Net.Mail.MailPriority]::High

        # Create from, to, and bcc
        $mail.From  = "opsmgr@stranger.local"
        $mail.To.Add($emailto)
        $mail.CC.Add("username@microsoft.com")
        $mail.BCC.Add(username@stranger.local)

        # Create the message
        $mail.Subject = "OpsMgr email with Company Knowledge" + " (" + [System.DateTime]::Now.ToString("yyyy-MM-dd HH:mm") + ")"
        $mail.Body = $body
        $mail.IsBodyHtml = $true

        # Set SMTP Server and create SMTP Client
        $smtp = new-object Net.Mail.SmtpClient
        $smtp.Host = "mail.stranger.local"
        $smtp.Port = "25"
        $smtp.EnableSsl = $false
        $smtp.Credentials = New-Object System.Net.NetworkCredential("username@stranger.nl", P@ssword);

        # Send message
        try {
           $smtp.Send($mail)
           Write-Host "Email is sent"
        }
        catch {
          "Exception caught: {0}" -f $Error[0]
        }
    }

    #Step 5. Clean up
    <#
        In this part of the script we are cleaning up.
        Remove the exported MP XML file.
    #>

    Function CleanUp($MPname)
    {
        remove-item ($env:TEMP+"\"+$MPname+".xml")
        Write-Host "Remove MP XML File"
        remove-pssnapin -name "Microsoft.EnterpriseManagement.OperationsManager.Client"
        cd $currentpath
        $AlertName = ""
       

    }


    #Main
     
    Initialize

    FindMonitorOrRuleForAlert $AlertName

    ExportMP -MPname $mpname -mpexportfolder ($env:TEMP)

    ParseCK -monitor $monitororrulename -mpexportfolder ($env:TEMP) -MPName $mpname

    EmailCK -emailto $emailto

    CleanUp -MPname $mpname

     

    Result:

    image

     

    image

     

    Have fun!F

Page 2 of 14 (349 items) 12345»