I've been asked to provide knowledge article to application owner in order to help them to determine what instruction to give to support level one for alert raised by SCOM management pack.
With no access to SCOM console, I didn't find an easy way to do it and I also decided to proceed with a powershell script.
Here are the command line I've written to export all product knowledge for rules and monitors for a specific MP. Create a PS1 file named ExportKnowledgeArticleFromAMP.ps1 and copy paste the command line from this post and go down and click download to get the PS1 file.
Usage a this script needs 2 parameters : MP name and Path to create files.
Example:
.\ExportKnowledgeArticleFromAMP.ps1 "Microsoft.Windows.Server.PrintServer.2012" "C:\Temp"
- param([string]$MPName, [string]$Path)
- # Script to export all product knowledge for rule and monitor for a specified MP
- # usage : .\ExportKnowledgeArticleFromAMP.ps1 "Microsoft.Windows.Server.PrintServer.2012" "C:\Temp"
- function MamlToHTML($MAMLText)
- {
- $HTMLText = "";
- $HTMLText = $MAMLText -replace('xmlns:maml="http://schemas.microsoft.com/maml/2004/10"');
- $HTMLText = $HTMLText -replace("maml:para","p");
- $HTMLText = $HTMLText -replace("maml:");
- $HTMLText = $HTMLText -replace("</section>");
- $HTMLText = $HTMLText -replace("<section>");
- $HTMLText = $HTMLText -replace("<section >");
- $HTMLText = $HTMLText -replace("<title>","<h2>");
- $HTMLText = $HTMLText -replace("</title>","</h2>");
- $HTMLText = $HTMLText -replace("<listitem>","<li>");
- $HTMLText = $HTMLText -replace("</listitem>","</li>");
- $HTMLText = "<html><body>" + $HTMLText + "</body></html>";
- $HTMLText;
- }
- # Mainline
- # Clear the screen.
- cls;
- # Get US Culture information.
- $ciUS = [System.Globalization.CultureInfo]'en-US';
- # Retrieve the Management Pack.
- $mps = get-managementpack
- $mp = $mps | ? { $_.Name -eq $MPName}
- $FolderName = $MPName + " - " + $mp.version
- # Create Folder
- New-Item -ItemType directory -Path $Path\$FolderName
- # Retrieve the Management Pack rules and monitors.
- $rules = $mp.getrules()
- $monitors = $mp.getmonitors()
- cls
- # Retrieve the knowledge Article for rules.
- $i = 1
- $j = 1
- foreach ($rule in $rules) {
- $article = $rule.GetKnowledgeArticle($ciUS);
- if ($article -ne $Null)
- {
- if ($article.MamlContent -ne $Null)
- {
- $article_text = $article.MamlContent;
- $article_text = MamlToHTML($article_text);
- }
- write-host "Outputing HTML...";
- if ($rule.DisplayName -ne "")
- {
- $RuleName = "Rule - " + [string]$i + " - " + [string]$rule.DisplayName
- }
- else
- {
- $RuleName = "Rule - " + [string]$i + " - " + [string]$rule.Name
- }
- # < > : " / \ | ? * removal
- $RuleName
- $RuleName = $RuleName.replace('<','lower than')
- $RuleName = $RuleName.replace('>','Greater than')
- $RuleName = $RuleName.replace('/','')
- $RuleName = $RuleName.replace('|','')
- $RuleName = $RuleName.replace('\','')
- $RuleName = $RuleName.replace('!','')
- $RuleName = $RuleName.replace('?','')
- $RuleName = $RuleName.replace('*','')
- $RuleName = $RuleName.replace(':','')
- $RuleName = $RuleName.replace(';','')
- $ExportFile = $Path + "\" + $FolderName + "\" + $RuleName + ".htm";
- $article_text.tostring() | out-file $ExportFile
- $i = $i + 1
- }
- }
- # Retrieve the knowledge Article for monitors.
- foreach ($monitor in $monitors) {
- $article = $monitor.GetKnowledgeArticle($ciUS);
- if ($article -ne $Null)
- {
- if ($article.MamlContent -ne $Null)
- {
- $article_text = $article.MamlContent;
- $article_text = MamlToHTML($article_text);
- }
- write-host "Outputing HTML...";
- if ($monitor.DisplayName -ne "")
- {
- $MonitorName = "Monitor - " + [string]$j + " - " + [string]$monitor.DisplayName
- }
- else
- {
- $MonitorName = "Monitor - " + [string]$j + " - " + [string]$monitor.Name
- }
- # < > : " / \ | ? * removal
- $MonitorName
- $MonitorName = $MonitorName.replace('<','lower than')
- $MonitorName = $MonitorName.replace('>','Greater than')
- $MonitorName = $MonitorName.replace('/','')
- $MonitorName = $MonitorName.replace('|','')
- $MonitorName = $MonitorName.replace('\','')
- $MonitorName = $MonitorName.replace('!','')
- $MonitorName = $MonitorName.replace('?','')
- $MonitorName = $MonitorName.replace('*','')
- $MonitorName = $MonitorName.replace(':','')
- $MonitorName = $MonitorName.replace(';','')
- $ExportFile = $Path + "\" + $FolderName + "\" + $MonitorName + ".htm";
- $ExportFile
- $article_text.tostring() | out-file $ExportFile
- $j = $j + 1
- }
- }
Executing the script will create a folder
Microsoft.Windows.Server.PrintServer.2012 - 6.0.7004.0 that contains an HTML file for each monitor/rules.
Note :
The script sometimes return errors on some monitors or rules - I guess the conversion to HTML is failing - but in that case, the impact is that the HTML file is not created for that rule/monitor.
The script can be easily adapted of courses to run on OpsMgr 2012.
I'll publish a page on my blog
>>>> HERE <<<< with all the product knowledge for all the provided MP I've in my environment.
This posting is provided "AS IS" with no warranties.