• Finding Management Packs from Microsoft Download website using PowerShell

    I don’t know if you noticed but Daniel Savage started a blog series about how we are raising the bar with respect to Management Packs. Daniel is responsible for all things related to Operations Manager Management Packs including customer satisfaction related to MPs for Microsoft server workloads.

    In his first blogpost he also references a Wiki Management Pack page on Microsoft Technet.

    So I thought it would be cool to be able to scrape some of the information about Management Packs using PowerShell. With some help from Jeff Wouters it turned out not to be that difficult.

    $hsg = Invoke-WebRequest -Uri "http://social.technet.microsoft.com/wiki/contents/articles/16174.microsoft-management-packs.aspx"
    $hsg.Links | Where-Object {($_.href -like "*http://www.microsoft.com/*download*") -and ($_.outerText -notlike "*Link to download page*") -and ($_.InnerHTML -like "*This link*")} | 
    Select @{Label="Management Pack";Expression={$_.InnerText}}, @{Label="Download Link";Expression={$_.href}}

    image

    [xml]$hsg = Invoke-WebRequest "http://social.technet.microsoft.com/wiki/contents/articles/16174.microsoft-management-packs/rss.aspx"
    
    $hsg.rss.channel.item | select Title, pubDate, creator

    image

     

    You could use some of the code to create some monitor to check for new Management Pack updates, using the RSS feed or some other fun stuff.

    Have fun!

  • Retrieving Management Pack Reference Aliases using PowerShell

    Today I was playing around with some MP Authoring automation using PowerShell and I needed to retrieve the Management Pack Reference Alias within a Management Pack. If you export a Management Pack to XML using the Get-SCOMManagementPack Cmdlet you can view the XML file and its contents.

    Get-SCOMManagementPack -Name Stefan.Test.MP | Export-SCOMManagementPack -Path c:\temp

    If you look at the exported MP XML file you can see the Management Pack Reference Aliases.

    <ManagementPack ContentReadable="true" SchemaVersion="2.0" OriginalSchemaVersion="1.1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <Manifest>
        <Identity>
          <ID>Stefan.Test.MP</ID>
          <Version>1.0.0.0</Version>
        </Identity>
        <Name>Stefan - Test MP</Name>
        <References>
          <Reference Alias="MicrosoftWindowsLibrary7585010">
            <ID>Microsoft.Windows.Library</ID>
            <Version>7.5.8501.0</Version>
            <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
          </Reference>
          <Reference Alias="SystemLibrary7585010">
            <ID>System.Library</ID>
            <Version>7.5.8501.0</Version>
            <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
          </Reference>
          <Reference Alias="SystemCenter">
            <ID>Microsoft.SystemCenter.Library</ID>
            <Version>7.0.8432.0</Version>
            <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
          </Reference>
          <Reference Alias="Health">
            <ID>System.Health.Library</ID>
            <Version>7.0.8432.0</Version>
            <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
          </Reference>
          <Reference Alias="MicrosoftSystemCenterInstanceGroupLibrary7585010">
            <ID>Microsoft.SystemCenter.InstanceGroup.Library</ID>
            <Version>7.5.8501.0</Version>
            <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
          </Reference>
        </References>

    But you know me, I don’t want to export the XML file and open it to see the Reference Aliases Smile We have  PowerShell so we are going to use it.

    How can we retrieve this info using PowerShell in the PowerShell OperationsManager Console?

    $mp = Get-SCOMManagementPack -name Stefan.Test.MP
    
    $alias = ($mp.References | where {$_.Value -like "*Microsoft.Windows.Library*"}).key
    
    $alias

    This will give us the Alias for the Microsoft.Windows.Library.

    image

    Next time more on how we could use this information to do some MP Authoring automation.

     

    Have a nice Easter weekend and maybe I see you at MMS in Las Vegas or the PowerShell Summit in Redmond!

  • Retrieving the network devices being monitored by OM2012 using PowerShell

    Today I got a question from a co-worker about retrieving the monitored network devices by OM2012 using PowerShell. For Agents it’s pretty simple, you just use the Get-SCOMAgent Cmdlet and you have a nice overview of the Agents being monitored by OM2012.

    But which Cmdlet should you use to get an overview of the monitored network devices? There is no Get-SCOMNetworkDevice Cmdlet.

    To retrieve the network devices being monitored by OM2012, you need the following Cmdlets Get-SCOMClass and Get-SCOMClassInstance.

    Get-SCOMClass -DisplayName "Network Device" | Get-SCOMClassInstance

    image

    image

    If you want to retrieve some more info about the network devices being monitored you can use the following PowerShell commands.

    $SCOMNetworkDevices = Get-SCOMClass -DisplayName "Network Device" | Get-SCOMClassInstance
    
    $SCOMNetworkDevices | Format-List *
    
    $SCOMNetworkDevices | select ManagementGroup, DisplayName, @{Label="AccessMode";Expression={$_.'[System.NetworkManagement.Node].AccessMode'}},
                             @{Label="Certification";Expression={$_.'[System.NetworkManagement.Node].Certification'}}, 
                             @{Label="SystemObjectId";Expression={$_.'[System.NetworkManagement.Node].SystemObjectId'}}
    

    image

     

    DISCLAMER: This Sample Code is provided for the purpose of illustration only.
    THIS SAMPLE CODE AND ANY RELATED INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
    LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. 

    We grant You a nonexclusive, royalty-free right to use and modify the Sample Code and to reproduce and distribute
    the object code form of the Sample Code, provided that You agree: (i) to not use Our name, logo, or trademarks to market Your software
    product in which the Sample Code is embedded; (ii) to include a valid copyright notice on Your software product in which the Sample Code is
    embedded; and (iii) to indemnify, hold harmless, and defend Us and Our suppliers from and against any claims or lawsuits, including
    attorneys' fees, that arise or result from the use or distribution of the Sample Code.