Export SCOM Rule and Monitor Knowledge Articles with PowerShell


 

Export-SCOMKnowledge.ps1 : Download at TechNet Gallery

This will output workflow information (including Knowledge Article content) to an HTML report or CSV file. Script accepts one or more (or all) management pack objects as input. Can export from SCOM using the SDK connection OR from management pack files.

Report Example

Export-SCOMKnowledge_Report1

Usage Examples

All Active Directory Management Packs:

Export-SCOMKnowledge0

Export-SCOMKnowledge1

Export-SCOMKnowledge2

Export-SCOMKnowledge_Explorer1

(Get-SCOMManagementPack -Name *.AD.*) | .\Export-SCOMKnowledge.ps1 -OutFolder 'C:\MyReports' -Topic "AD_" -ShowResult

In the example above the variable will be assigned a collection of all management pack objects with ".AD." in the name.
That subset/collection of management pack objects will be passed into the script. The script will output workflow details for all Rules and Monitors contained in ALL management packs within that set.
The output file names will be: "AD_Rules.html" and "AD_Monitors.html". Finally the script will open Windows File Explorer to the location of the output directory.

 

All Active Directory Management Packs with Filtered Workflow Name:
.\Export-SCOMKnowledge.ps1 -OutFolder 'C:\Export' -ManagementPack (Get-SCOMManagementPack -Name "*ad.*") -Filter '201[0-6]'

The command above will output all rules/monitors from management packs which contain 'ad.' in the Name and which contain '201x' in the Name or DisplayName of the workflow where 'x' represents any single digit 0-6 .

.\Export-SCOMKnowledge.ps1 -OutFolder 'C:\Export' -ManagementPack (Get-SCOMManagementPack -Name "*ad.*") -Filter '(?=200[0-8])((?!Monitoring).)*$'

The command above will output all rules/monitors from management packs which contain 'ad' in the Name and which contain '200x' in the Name or DisplayName of the workflow where 'x' is numbers 1-8 but excluding workflows that contain 'monitoring'.

 

All SQL MPs:
.\Export-SCOMKnowledge.ps1 -OutFolder "C:\Temp" -ManagementPack (Get-SCOMManagementPack -Name *SQL*) -Topic "SQL_Packs_"

The command above will output workflow details for all Rules and Monitors contained in ALL management packs with "SQL" in the management pack Name.  The output file names will be: "SQL_Packs_Rules.html" and "SQL_Packs_Monitors.html"

 

ALL Rules and Monitors in the SCOM Management Group:
.\Export-SCOMKnowledge.ps1 -OutFolder "C:\MyReports" -ManagementServer "ms01.contoso.com" -NoKnowledgeExclude

In the example above, the command will connect to management server: "ms01.contoso.com", will output workflow details for all Rules and Monitors (only if they contain a Knowledge Article) to two separate files in the specified folder. The output file names will be: "Rules.html" and "Monitors.html"

 

This is a way to use management pack files (.mp and .xml) from a directory path with specific topics.
The below script example will use management pack files which names match the array of Topics.
##---- CONFIGURE THESE VARIABLES ----##
# Location of management pack files
$inDir = 'C:\Program Files (x86)\System Center Management Packs\'
# Output directory
$outDir = 'C:\'
# Management pack file names which match these strings will be selected
$topics = "DHCP,DNS,FileServices,GroupPolicy,DFS,FileReplication"
##---- CONFIGURE THESE VARIABLES ----##

$FilePaths =@()
$h = @{}
# Will export data for each management pack file name matching the topic name. 
ForEach ($topic in $topics.Split(',')){
    Write-Host "Topic: $topic" -BackgroundColor Black -ForegroundColor Yellow
    $FilePaths = Get-ChildItem -Recurse -Include "*$topic*.mp*","*$topic*.xml*" -File -Path $inDir | Select fullname
    $FilePaths | ForEach {$h.(Split-Path $_.FullName -Leaf) = $_.FullName }
    If (!($h.Count)){ Continue;} #If no matching file found, skip to next topic
    $h.Keys
    ""
    $MPs = (Get-SCOMManagementPack -ManagementPackFile ($h.Values | % {$_} )  )
    & '.\Export-SCOMKnowledge.ps1' -OutFolder $outDir -ManagementPack $MPs -Topic $Topic
}

 

Related:

How to Get Knowledge Article from a SCOM Alert with Powershell


Comments (0)

Skip to main content