Showing posts with label SCOM. Show all posts
Showing posts with label SCOM. Show all posts

Monday, May 18, 2015

System Center Operations Manager Customer Survey

The Operations Manager team is interested in your feedback! They are committed to keeping customers like you happy and productive. Your response to this survey will help them better understand your needs and problems so that they can improve the next version of Operations Manager.



To answer the survey, click >>>   HERE   <<<
 

This posting is provided "AS IS" with no warranties.

Wednesday, November 27, 2013

Florian Aguettaz IT Blog: [System Center] Full review of all System Center product ( #SystemCenter )

Florian Aguettaz is posting a full review of all System Center products. There are currently 7 products in the System Center Suite that are used to cover all the ITIL best practices. Each one will be detailed in different post on his blog.


This posting is provided "AS IS" with no warranties.

Monday, July 1, 2013

[Orchestrator] Integrating Cluster Aware Updating with Operations Manager Maintenance Mode – Pre and Post Update Scripts ( #SCOM #Orchestrator )


Neil Peterson has published on June the 17th 2013 a step-by-step post to demonstrating how to use the Cluster Aware Updating Pre and Post-Update Script execution feature to place each node of the target cluster into Operations Manager maintenance mode before the cluster aware updating process is executed. This exercise can be extended to any pre or post activates that you would like to perform on you cluster nodes at maintenance time.



This posting is provided "AS IS" with no warranties.

[System Center Suite] Download and test system center suite 1012 R2 Preview (#SystemCenter #SCOM #DPM #Orchestrator #SCSM #VMM #SCCM #OpsMgr)



The following links take you to the What's New topics for System Center 2012 R2.





You can download product here:

This posting is provided "AS IS" with no warranties.

Thursday, April 4, 2013

[OpsMgr 2007 R2] Powershell script to export all product knowledge for rule and monitor for a specific MP

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"

  1. param([string]$MPName, [string]$Path)
  2. # Script to export all product knowledge for rule and monitor for a specified MP 
  3. # usage : .\ExportKnowledgeArticleFromAMP.ps1 "Microsoft.Windows.Server.PrintServer.2012" "C:\Temp"
  4. function MamlToHTML($MAMLText)
  5. {
  6.  $HTMLText = "";
  7.  $HTMLText = $MAMLText -replace('xmlns:maml="http://schemas.microsoft.com/maml/2004/10"');
  8.  $HTMLText = $HTMLText -replace("maml:para","p");
  9.  $HTMLText = $HTMLText -replace("maml:");
  10.  $HTMLText = $HTMLText -replace("</section>");
  11.  $HTMLText = $HTMLText -replace("<section>");
  12.  $HTMLText = $HTMLText -replace("<section >");
  13.  $HTMLText = $HTMLText -replace("<title>","<h2>");
  14.  $HTMLText = $HTMLText -replace("</title>","</h2>");
  15.  $HTMLText = $HTMLText -replace("<listitem>","<li>");
  16.  $HTMLText = $HTMLText -replace("</listitem>","</li>");
  17.  $HTMLText = "<html><body>" + $HTMLText + "</body></html>";
  18.  $HTMLText;
  19. }
  20. # Mainline
  21. # Clear the screen.
  22. cls;
  23. # Get US Culture information.
  24. $ciUS = [System.Globalization.CultureInfo]'en-US';
  25. # Retrieve the Management Pack.
  26. $mps = get-managementpack
  27. $mp = $mps | ? { $_.Name -eq $MPName}
  28. $FolderName = $MPName + " - " + $mp.version
  29. # Create Folder
  30. New-Item -ItemType directory -Path $Path\$FolderName
  31. # Retrieve the Management Pack rules and monitors.
  32. $rules = $mp.getrules()
  33. $monitors = $mp.getmonitors()
  34. cls
  35. # Retrieve the knowledge Article for rules.
  36.  $i = 1
  37.  $j = 1
  38. foreach ($rule in $rules) {
  39.  $article = $rule.GetKnowledgeArticle($ciUS);
  40.  if ($article -ne $Null)
  41.  {
  42.   if ($article.MamlContent -ne $Null)
  43.   {
  44.     $article_text = $article.MamlContent;
  45.     $article_text = MamlToHTML($article_text);
  46.   }
  47.   write-host "Outputing HTML...";
  48.   if ($rule.DisplayName -ne "")
  49.     {
  50.     $RuleName = "Rule - " + [string]$i + " - " + [string]$rule.DisplayName
  51.     }
  52.   else
  53.     {
  54.     $RuleName = "Rule - " + [string]$i + " - " + [string]$rule.Name
  55.     }
  56.   # < > : " / \ | ? * removal
  57.    $RuleName
  58.   $RuleName = $RuleName.replace('<','lower than')
  59.   $RuleName = $RuleName.replace('>','Greater than')
  60.   $RuleName = $RuleName.replace('/','')
  61.   $RuleName = $RuleName.replace('|','')
  62.   $RuleName = $RuleName.replace('\','')
  63.   $RuleName = $RuleName.replace('!','')
  64.   $RuleName = $RuleName.replace('?','')
  65.   $RuleName = $RuleName.replace('*','')
  66.   $RuleName = $RuleName.replace(':','')
  67.   $RuleName = $RuleName.replace(';','')
  68.   $ExportFile = $Path + "\" + $FolderName + "\" + $RuleName + ".htm";
  69.   $article_text.tostring() | out-file $ExportFile
  70.   $i = $i + 1
  71.  }
  72. }
  73. # Retrieve the knowledge Article for monitors.
  74. foreach ($monitor in $monitors) {
  75.  $article = $monitor.GetKnowledgeArticle($ciUS);
  76.  if ($article -ne $Null)
  77.  {
  78.   if ($article.MamlContent -ne $Null)
  79.   {
  80.     $article_text = $article.MamlContent;
  81.     $article_text = MamlToHTML($article_text);
  82.   }
  83.   write-host "Outputing HTML...";
  84.    if ($monitor.DisplayName -ne "")
  85.     {
  86.     $MonitorName = "Monitor - " + [string]$j + " - " + [string]$monitor.DisplayName
  87.     }
  88.    else
  89.      {
  90.     $MonitorName = "Monitor - " + [string]$j + " - " + [string]$monitor.Name
  91.     }
  92.   # < > : " / \ | ? * removal
  93.    $MonitorName
  94.   $MonitorName = $MonitorName.replace('<','lower than')
  95.   $MonitorName = $MonitorName.replace('>','Greater than')
  96.   $MonitorName = $MonitorName.replace('/','')
  97.   $MonitorName = $MonitorName.replace('|','')
  98.   $MonitorName = $MonitorName.replace('\','')
  99.   $MonitorName = $MonitorName.replace('!','')
  100.   $MonitorName = $MonitorName.replace('?','')
  101.   $MonitorName = $MonitorName.replace('*','')
  102.   $MonitorName = $MonitorName.replace(':','')
  103.   $MonitorName = $MonitorName.replace(';','')
  104.   $ExportFile = $Path + "\" + $FolderName + "\" + $MonitorName + ".htm";
  105.   $ExportFile
  106.   $article_text.tostring() | out-file $ExportFile
  107.    $j = $j + 1
  108.  }
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.


Here is a link where you can download my script : ExportKnowledgeArticleFromAMP.ps1



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.

Thursday, January 31, 2013

[OpsMgr 2012][Powershell] Get Alerts for all specified SCOM MP using powershell in Operations Manager 2012


Here is a short powershell script I've just updated to be usable in operations Manager 2012 since cmdlet have been renamed. This script will help you to retrieve alerts from a specified SCOM MP using powershell.
 

Note that previous version dedicated to Operations Manager 2007 R2 is here
  
Here is the new script :

  1. $mp = Get-SCOMManagementPack -name 'MPName'
  2. # Criteria       : All alerts, raw and processed descriptions.
  3. # Output to      : File (c:\temp\output\Alerts-all.csv)
  4. # Fields Selected: Lots.
  5. # Output Format  : CSV
  6. # Notes          : Need more work on this.
  7. $alerts_csv = "C:\MPName.csv";
  8. write-host "Exporting all alerts to csv: ",$alerts_csv;
  9. Get-SCOMAlert | select-object @{Name = '%'; expression ={$_.MonitoringObjectDisplayName}},Severity, Name, ResolutionState, RepeatCount,@{Name = 'Instances'; expression ={$_.RepeatCount+1}},@{Name = 'Created'; expression =
  10. {$_.TimeRaised.ToLocalTime()}},@{Name = 'Description (Processed)';Expression = {$_.Description  -replace "`n"," " -replace " "," "}},MonitoringObjectFullName, IsMonitorAlert,Id,MonitoringRuleId,MonitoringClassId,Description | sort Name | export-csv $alerts_csv -noTypeInformation;
 Replace MPName in red by the your MP Name. Il will export all alerts in a CSV file.

This posting is provided "AS IS" with no warranties.

Monday, October 8, 2012

[SCOM 2007] Authoring Management Pack - Create a VBS discovery with a debugging functionnality - PART III

The first time the discovery script given in Part II is executed on a targeted machine, it try to read the debugging key in the registry.
If the key is not found, it creates a it in HKLM\SOFTWARE\Microsoft\Microsoft Operations Manager\Debugging.

The default value for the key is FALSE - That means that all the functions that are used for the debugging mode (See PART I) will not work.
If you want to activate the debugging mode on a specific server, just change the key value to TRUE on this server.


When discovery has run, you also have a property discovered in your main class that reflect the debug mode value.

It's now easy to work with the function that creates events in the Operations Manager Event Log in your script :

call sub_LogMPScriptEvent (10211, "My Event", Err, DebugModeValue,strMPScriptName,MOMEVENTLOGINFORMATION)

Where
- DebugModeValue is set with the value of the registry key created/read by the discovery
- strMPScriptName is the name of the discovery script
- MOMEVENTLOGINFORMATION is set with value 0
- 10211 will be the event number created in Operations Manager Event log.


Why using this debug mode : 

Last time I've used this key was to understand why my discovery script was well working when I was launching the VBS with a cscript with parameter in a shell (no script issue, property bags were set) but when the Discovery was lauched by SCOM, nothing was discovered !
I've also create an event that give all the variable used to set the property bags, imported the new MP, change the key on the server to set the debug mode to TRUE and force the discovery.

Analysing the Operations Manager log show me that I' was using a variable that didn't reflect the computer name and was always set to the same value... meaning that SCOM was not abled to discovers the services for the computer name since the computer name had a false value.

I've change the script to use the good displayName for the computer and tested it. The discovery was always working with no errors but this time, services were discovered ! :)

If you have any question, don't hesitate to contact me.

This posting is provided "AS IS" with no warranties.

Thursday, February 16, 2012

[Authoring MP] MPBPA analysis tool always report "Alerts should have name and description defined"

This is related to the alert configuration. You must verify that
  • when you open a rule, switch to configuration and check what is missing in the alert section.
  • If it's not there, check display name and description for the alert.
If you have separated out your strings into a language pack instead of putting the english strings into the base MP, then you will have to live with this error.
A best practice should be to have a base MP contains only the ENU strings.

This posting is provided "AS IS" with no warranties.

Wednesday, January 18, 2012

Don't Miss MMS 2012 !

http://www.mms-2012.com/

About MMS

The Microsoft Management Summit (MMS) is your opportunity to gain expertise through deep technical training, hands-on learning, and valuable interaction with your peers and industry leaders.
MMS cuts through the marketing noise so you can learn the latest desktop and device management, datacenter and cloud technologies to help you solve today’s challenges. From keynotes to sessions to hands-on labs, certification opportunities, and face-to-face access to Microsoft and industry experts, MMS provides a “can’t-miss” opportunity to be among the first to learn about new technologies.

Why You Won’t Want to Miss It

Intensive week of technical training
  • MMS delivers the deepest level of technical training offered by Microsoft with hundreds of learning opportunities
  • In addition to hearing from Microsoft, you'll learn about best practices from your peers and pioneers in client and device management, datacenter, and cloud technologies with an extensive line up of technical experts


You’ll be first to test drive new products and solutions
  • At MMS you will be the first to preview upcoming product releases
  • You’ll also gain free access to valuable trial software
  • Over 50 technology companies will be exhibiting their latest innovations and technology solutions


You’ll learn how to accelerate your career
  • MMS helps you be successful with Microsoft's industry-recognized certification opportunities
  • MMS serves up career insights from industry experts that can help you advance your career


You’ll experience the power of community
  • Build lasting relationships your peers and industry-leading experts in an environment designed to foster the exchange of ideas
  • Connect one-on-one or in groups with structured and unstructured networking opportunities througout the event
  • Experience the fun side of technology events with cool social functions


This posting is provided "AS IS" with no warranties.

Tuesday, January 17, 2012

[Powershell] Configure Failover Management Server on SCOM Agent with Powershell

Here are some powershell command line you can use to configure failover on SCOM agent like this :



  1. # First retrieve information on the management servers
  2. $managementservers = get-managementserver
  3. $GTWServer1 = $managementservers | where {$_.Name -eq "GTWServer1.domain"};
  4. $GTWServer2 = $managementservers | where {$_.Name -eq "GTWServer2.domain"};
  5. # Settting up the failover between agents and Gateways
  6. Get-Agent -ManagementServer $GTWServer1 | foreach {set-managementserver -agentmanagedcomputer $_ -primarymanagementserver $GTWServer1 -failoverserver $GTWServer2 }
  7. Get-Agent -ManagementServer $GTWServer2 | foreach {set-managementserver -agentmanagedcomputer $_ -primarymanagementserver $GTWServer2 -failoverserver $GTWServer1 }

This posting is provided "AS IS" with no warranties.

Monday, January 16, 2012

SCOM 2012 Servers sizing for a small SCOM 2007 new deployment

For my own job, I've to create a new SCOM 2007 infrastructure (less than 250 servers to monitor - 120 servers in the same domain - 120 servers in 10 others domains).

I've also define 2 screnarios according to the Microsoft recommendations.

  • scenario given by Microsoft – small deployment

HW Mini required


Role: Root Management Server• 2 disk RAID 1
• 4 GB RAM
• Dual Proc

Role: Operations Database Server,  & Operations Data Warehouse Server (w/ SRS & Web Console Server)• 6 disk RAID 10 (147GB)
• 4 GB RAM
• Dual Proc



  • More secure scenario
The idea is to have a secure infrastructure for all monitored servers and a SCOM 2012 compliantcyto be sure if one day we have to migrate to SCOM 2012 - no new server will be needed.

So here is the minimal requisite for a small SCOM 2012 infrastructure (Minimal Hardware is given since we don't have a the moment any Microsoft recommandations):




and here is a more secure Topology Diagram :

SQL DB/DW on a cluster
SQL reporting server on the passive node since cluster is not supported
Servers outside the domain 1 will be linked to MS + RMS (failover) by using certificate
Servers in Domain 1 will be attached to 2 gateways (one for failover)
Console will be installed on a management server


This posting is provided "AS IS" with no warranties.

Friday, January 13, 2012

TechNet Virtual Lab: System Center Operations Manager 2012: Infrastructure and Application Performance Monitoring

Microsoft Virtual Lab on SCOM 2012 is available

https://cmg.vlabcenter.com/default.aspx?moduleid=7a804b17-0025-4309-957d-a21c2e121e2b

Deploying the infrastructure for a private cloud is just the first step. Once it’s in place, IT administrators have to monitor those resources to ensure that the infrastructure SLAs are met, quickly find the causes for any problems, and plan for future growth.

This posting is provided "AS IS" with no warranties.

[OpsMgr 2007 R2][Powershell] Get Alerts for all specified SCOM MP using powershell in Operation Manager 2007 R2

Here is a short powershell script you can use to retrieve alerts froml a specified SCOM MP using powershell.

  1. $mp = Get-ManagementPack -name 'MPName'
  2. # Criteria       : All alerts, raw and processed descriptions.
  3. # Output to      : File (c:\temp\output\Alerts-all.csv)
  4. # Fields Selected: Lots.
  5. # Output Format  : CSV
  6. # Notes          : Need more work on this.
  7. $alerts_csv = "C:\MPName.csv";
  8. write-host "Exporting all alerts to csv: ",$alerts_csv;
  9. Get-Alert | select-object @{Name = '%'; expression ={$_.MonitoringObjectDisplayName}},Severity, Name, ResolutionState, RepeatCount,@{Name = 'Instances'; expression ={$_.RepeatCount+1}},@{Name = 'Created'; expression =
  10. {$_.TimeRaised.ToLocalTime()}},@{Name = 'Description (Processed)';Expression = {$_.Description  -replace "`n"," " -replace " "," "}},MonitoringObjectFullName, IsMonitorAlert,Id,MonitoringRuleId,MonitoringClassId,Description | sort Name | export-csv $alerts_csv -noTypeInformation;
 Replace MPName in red by the your MP Name. Il will export all alerts in a CSV file.



An updated version for Operations Manager 2012 has been published >>>>>>>>>> here <<<<<<<<<<

This posting is provided "AS IS" with no warranties.

Thursday, December 1, 2011

[OpsMgr 2007] Timeout running Remove-DisabledMonitoringObject cmdlet in System Center Operations Manager

I've read a lot and seen a lot of cases like mine - I mean remove-disabledmonitoringobject cmdlet get the error "The requested operation timed out" but it seems that nobody has been lucky to found how to fix the issue. We have openned a Micorsoft case on this issue a lot of monthes ago and since the begining of the week, we are now able to run the cmdlet without any error.

This resolution given by Microsoft for an openned case will not be part of the CU6.
The resolution has been found too late !


First, here is our configuration - approximatly 3000 agents in CU3. We don't have upgraded to CU4 and we soon upgrade to CU5. SQL 2008 for the DBs.

The first thinking of why the cmdlet is timing out was the number of overrides was too much for the SDK to process before the thirty minute WCF(Windows Connection Framework) timeout occurs.

Within our production environment there are approximately 140000 DiscoverySources which need analyse be the cmdlet to know if the associated discovered types need to be removed or not. We have a pre-production environnemnt with less number of agents and only 40000 DiscoverySources on wich the cmdlet is well working.

To reduce the number of Discovery sources we have analysed all the MP we have and it appeared that OCS MP was responsible for almost 40% of the hugh number of DiscoverySources. The OCS MP has nineteen discoveries targeted at Windows Server Computer class enabled by default. On each discoveries we have an override on a group to disable disovery for the group members. A discoverysource entry is created for each discovery-to-target-entity mapping.
We have also :  19 * ~3000 agents = 57000 discoverysources just for OCS MP.
When overrides are done one theses discoveries, the enabled states must calculated for all discoverysources !

I've worked to remove some overrides and also to reduce the enabled state calculation for the DiscoverySources but the cmdlet was always timed out.

The next way to fix the issue was to let Microsoft have an other review of the code and SQL involved to see if they can make some efficiencies in the way they do this. I've also been asked to run 2 queries on the SCOM Database :
I’ve also run the following queries :

  1. SELECT COUNT (Distinct [DiscoverySource].[DiscoverySourceId])
  2. FROM dbo.DiscoverySource
  3. INNER JOIN dbo.ModuleOverride ON ModuleOverride.ParentId = DiscoverySource.DiscoveryRuleId
  4. AND ModuleOverride.OverrideableParameterId = dbo.fn_MPObjectId(NULL, NULL, N'Enabled')
  5. AND (ParentType = 'Discovery' OR ParentType = 'Rule')
  6. join DiscoverySourceToTypedManagedEntity dstme
  7. on discoverysource.DiscoverySourceId = dstme.DiscoverySourceId
  8. WHERE DiscoverySource.IsDeleted = 0
  9. AND ModuleOverride.Value = 'false'

  1. SELECT COUNT (Distinct [DiscoverySource].[DiscoverySourceId])
  2. FROM dbo.DiscoverySource
  3. INNER JOIN dbo.ModuleOverride ON ModuleOverride.ParentId = DiscoverySource.DiscoveryRuleId
  4. AND ModuleOverride.OverrideableParameterId = dbo.fn_MPObjectId(NULL, NULL, N'Enabled')
  5. AND (ParentType = 'Discovery' OR ParentType = 'Rule')
  6. join DiscoverySourceToTypedManagedEntity dstme
  7. on discoverysource.DiscoverySourceId = dstme.DiscoverySourceId
  8. WHERE DiscoverySource.IsDeleted = 0
Given the numbers returned by the queries Microsoft support suspects the step below will allow the cmdlet to complete and await your results.
Here is also what I've been asked to do :
  • Run the SQL against the OperationsManager DB.

  1. DECLARE @querydef XML
  2. SET @querydef =
  3. N'<QueryDefinitions xmlns="urn:DataAccess" xmlns:dal="urn:DataAccess" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:DataAccess QueryDefinition.xsd">
  4. <QueryDefinition>
  5.   <Name>DiscoverySourcesEligibleForDeletionDueToOverrides</Name>
  6.   <ObjectName>DiscoverySourcesEligibleForDeletionDueToOverrides</ObjectName>
  7.   <UsedBy Component="Sdk" />
  8.   <Description>Selects discovery sources that *may* be invalid due to applied overrides.</Description>
  9.   <DataObject xsi:type="SelectType">
  10.     <Column>
  11.       <Name>DiscoverySourceId</Name>
  12.       <Source>DiscoverySource</Source>
  13.       <Type>uniqueidentifier</Type>
  14.     </Column>
  15.     <Column>
  16.       <Name>DiscoverySourceType</Name>
  17.       <Source>DiscoverySource</Source>
  18.       <Type>tinyint</Type>
  19.       <EnumType>Microsoft.EnterpriseManagement.Mom.Modules.DataItems.Discovery.DiscoverySourceType</EnumType>
  20.       <EnumLeastValue>Rule</EnumLeastValue>
  21.       <EnumGreatestValue>ConfigService</EnumGreatestValue>
  22.     </Column>
  23.     <Column>
  24.       <Name>DiscoveryRuleId</Name>
  25.       <Source>DiscoverySource</Source>
  26.       <Type>uniqueidentifier</Type>
  27.     </Column>
  28.     <Column>
  29.       <Name>BoundManagedEntityId</Name>
  30.       <Source>DiscoverySource</Source>
  31.       <Type>uniqueidentifier</Type>
  32.     </Column>
  33.     <Argument>Distinct</Argument>
  34.     <Source>
  35.       <Table>
  36.         <Name>DiscoverySource</Name>
  37.         <Owner>dbo</Owner>
  38.         <Type>Table</Type>
  39.       </Table>
  40.       <Join>
  41.         <Type>Inner</Type>
  42.         <Table>
  43.           <Name>ModuleOverride</Name>
  44.           <Owner>dbo</Owner>
  45.           <Type>Table</Type>
  46.         </Table>
  47.         <JoinCondition>ModuleOverride.ParentId = DiscoverySource.DiscoveryRuleId AND ModuleOverride.OverrideableParameterId = dbo.fn_MPObjectId(NULL, NULL, N''Enabled'') AND (ParentType = ''Discovery'' OR ParentType = ''Rule'')</JoinCondition>
  48.       </Join>
  49.       <Join>
  50.         <Type>Inner</Type>
  51.         <Table>
  52.           <Name>DiscoverySourceToTypedManagedEntity</Name>
  53.           <Owner>dbo</Owner>
  54.           <Type>Table</Type>
  55.         </Table>
  56.         <JoinCondition> discoverysource.DiscoverySourceId = DiscoverySourceToTypedManagedEntity.DiscoverySourceId</JoinCondition>
  57.       </Join>
  58.     </Source>
  59.     <Conditional>
  60.       <Condition>
  61.         <Expression>DiscoverySource.IsDeleted = 0 AND ModuleOverride.Value = ''false''</Expression>
  62.       </Condition>
  63.     </Conditional>
  64.   </DataObject>
  65. </QueryDefinition>
  66. </QueryDefinitions>'
  67. INSERT INTO dbo.[DataAccessLayerSetting]([SettingType], [SettingData]) VALUES (0, @querydef)



The impact of this change is when the cmdlet is run, it will now use the SQL query inserted in the Data.AccessLayerSetting table instead of the Original SQL query which is compiled into one dll. This table allows us to override the in-built queries, as it is read on OMSDK service restart.Coming back to the origicnal SQL is very easy, just remove the entry in the Data.AccessLayerSetting table and restart the SDK.

  • Restart the OpsMgr SDK service.
  • Run the remove-disabledmonitoringobject cmdlet and report back on the success or failure of it.
I use to launch the cmdlet like this (in a short PS1):
  1. get-managementserver | select ManagementGroup -unique
  2. get-date
  3. remove-disabledmonitoringobject
  4. get-date
That permit to show in the same few line the OpsMgr group, the dates before and after the cmdlet has run.


 Unfortunatly the 2 first time I've launched the remove-disabledmonitoringobject cmdlet, it went to a new error :

  1. >get-date
  2. Monday, November 28, 2011 8:27:16 AM
  3. PS Monitoring:\
  4. >remove-disabledmonitoringobject
  5. Remove-DisabledMonitoringObject : Microsoft.EnterpriseManagement.Common.DiscoveryDataFromRuleTargetedToDeletedMonitoringObjectException: Discovery data has been received from a rule targeted at a non-existent monitoring object id.
  6. MonitoringObjectId: c1537246-ec53-cc7c-b45f-aed87f06bc7f
  7. RuleId: 66b6d462-535f-cab6-eb14-b24fc79dfb75
  8.    at Microsoft.EnterpriseManagement.DataAbstractionLayer.InstanceSpaceOperations.DeleteDisabledDiscoverySources()
  9.    at Microsoft.EnterpriseManagement.ManagementGroup.DeleteDisabledMonitoringObjects()
  10.    at Microsoft.EnterpriseManagement.OperationsManager.ClientShell.RemoveDisabledMonitoringObjectCmdlet.ProcessRecord()
  11. At line:1 char:32
  12. + remove-disabledmonitoringobject <<<<
  13.     + CategoryInfo          : InvalidOperation: (Microsoft.Enter...ingObjectCmdlet   :RemoveDisabledMonitoringObjectCmdlet) [Remove-DisabledMonitoringObject], Disc
  14.   overyDataFr...ObjectException    + FullyQualifiedErrorId : ExecutionError,Microsoft.EnterpriseManagement.Operat
  15.    ionsManager.ClientShell.RemoveDisabledMonitoringObjectCmdlet
  16. PS Monitoring:\
  17. >get-date
  18. Monday, November 28, 2011 8:48:55 AM
I've also report this again to the microsoft support and wait any answer. That particular seems to be known and the cmdlet completed without error on the second run. In my case, the second run of the cmdlet found a different object which caused again the error and as in the first run it set the original object’s IsDeleted property to 1. It appears that the cmdlet attempts remove some objects twice, and it's failing on the second attempt.
I've launched a third time the cmdlet and it ended in success ! 





This posting is provided "AS IS" with no warranties.

This posting is provided "AS IS" with no warranties.

[SCOM 2007] Authoring Management Pack - Create a VBS discovery with a debugging functionnality - PART II

Now we have all needed function (see PART I of this article), we can create a new Management Pack by using the authoring console.

Create a new MP with the Authoring Console : MyNewMP.xml witha "Microsoft.Windows.Local Application" Class nammed MyNewMP.CLS1.
Add a new property to this class : DebugMod



Then create a new discovery MyNewMP.DSC1 that target Microsoft.Windows.Server.Computer and discover the class MyNewMP.CLS1 and all its attributes.




Choose the disovery type : Microsoft.Windows.TimedScript.DiscoveryProvider and schedule it once a day and call your script MyNewMP.DSC1.script.vbs. Click on Parameters and add 3 parameters like :

$MPElement$ $Target/Id$ $Target/Property[Type="Windows!Microsoft.Windows.Computer"]/PrincipalName$

In the Script field you will have to paste the discovery script below :

  1. First part of the discovery script is to declare and set the variable
  2. Option Explicit
  3. SetLocale("en-us")
  4. '-----------------------------------------------------------------------------------------------------
  5. ' DEFAULT VARIABLES AND CONST - Used by the debuging functions and sub
  6. '-----------------------------------------------------------------------------------------------------
  7. Const REGKEYPATH = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft Operations Manager\Debugging"
  8. Const REGISTRYDEFVALUE = "FALSE"
  9. Const MOMEVENTLOGERROR = "1"
  10. Const MOMEVENTLOGWARNING = "2"
  11. Const MOMEVENTLOGINFORMATION = "4"
  12. Dim intIndex
  13. Dim strRegValue
  14. Dim strRegKeyName
  15. Dim strMPScriptName
  16. Dim strCurrentDebugModeValue
  17. Dim oAPI
  18. Dim oInst
  19. Dim oArgs
  20. Dim oDiscoveryData
  21. '-----------------------------------------------------------------------------------------------------
  22. ' SET THE FOLLOWING VALUES ACCORDING TO YOUR MANAGEMENT PACK
  23. '----------------------------------------------------------------------------------------------------
  24. strMPScriptName = "MyNewMP.DSC1.vbs"
  25. strRegKeyName = "Verbose.MyNewMP"
  26. '-----------------------------------------------------------------------------------------------------
  27. ' Create the object that connect to MOM API
  28. Set oAPI = CreateObject("MOM.ScriptAPI")
The second part of the discovery will be dedicated to all function seens in Part I of this article :

  1. '-----------------------------------------------------------------------------------------------------
  2. ' DEFAULT FUNCTIONS - Used for Management Pack debugging
  3. '-----------------------------------------------------------------------------------------------------
  4. Private Function fct_ReadRegistryKey(ByVal strKeyPath, ByVal strKeyName)
  5. 'Read Registry key located on KeyPath\KeyName
  6. 'Returns the value of a registry key and eventually a no-value to identify that the key does not exists.
  7.            Dim oWshShell
  8.             Dim strRegReadValue     'Contains the value of the Registry Key
  9.             'Try to read the registry key located to strKeyPath\strKeyName
  10.             On Error Resume Next
  11.             Set oWshShell = CreateObject("Wscript.Shell")
  12.             strRegReadValue = oWshShell.RegRead(strKeyPath &"\" & strKeyName)
  13.             'If an error is raised Then we a no-value to identify that the Registry Key does not exist.
  14.             If err.number <> 0 Then
  15.                         strRegReadValue = ""
  16.             End if
  17.             On error goto 0
  18.             fct_ReadRegistryKey = UCase(strRegReadValue)
  19. End Function
  20. '-----------------------------------------------------------------------------------------------------
  21. Private Function fct_WriteRegistryKey(ByVal strKeyPath, ByVal strKeyName, ByVal strKeyValue)
  22. ' Write a Registry value to strKeyPath\strKeyName with value strKeyValue
  23. ' blnKeyEdit is set to True or false in case of error.
  24.             Dim blnKeyEdit
  25.             Dim oWshShell
  26.             blnKeyEdit = false
  27.             'Try to set strKeyValue to the registry key strKeyPath\strKeyName
  28.             On Error Resume Next
  29.             Set oWshShell = WScript.CreateObject("WScript.Shell")
  30.             oWshShell.RegWrite strKeyPath & "\" & strKeyName , UCase(strKeyValue)
  31.             'If setting the registry key strKeyValue is OK Then the function will return a string TRUE.
  32.             If err.number = 0 Then
  33.                         blnKeyEdit = true
  34.             End if
  35.             On error goto 0
  36.             fct_WriteRegistryKey = blnKeyEdit
  37. End Function
  38. '-----------------------------------------------------------------------------------------------------
  39. Private Sub sub_LogMPScriptEvent(ByVal intErrNumber, ByVal strEventLogMessage, ByRef objError, ByVal strDebugMod, ByVal strScriptName, ByVal strMomEventLevel)
  40. ' Log an event in the OperationManager eventLog of the server if it is in debug mode
  41. ' It will allow to trace the debugging process of the script of the Management Pack by logging errors and parameters values
  42.             Dim strMessage
  43.              strMessage=""
  44.              'If the debug mode is ON, an event is logged in the Operation Manager eventLog.
  45.             If ucase(strDebugMod) = "TRUE" Then
  46.                         strMessage = strEventLogMessage & vbCrLf & " " & vbCrLf & _
  47.                         "Error number:" & vbTab & CStr(objError.Number) & vbCrLf & _ 
  48.                         "Error description:" & vbTab & objError.Description
  49.             Call oAPI.LogScriptEvent(strScriptName, intErrNumber, strMomEventLevel, strMessage)
  50.             End if
  51. End Sub
  52. '-----------------------------------------------------------------------------------------------------
  53. Private function fct_LogRunningAccount(ByVal strDebugMode)
  54. ' Log an event in the OperationManager eventLog of the server if it is in debug mode
  55. ' It allows to know under which credentials the script is executed
  56.             Dim owshNetwork
  57.             Dim strRunningUserID
  58.             On Error Resume Next
  59.             Set owshNetwork = WScript.CreateObject("WScript.Network")
  60.             'Assign user name returned to a variable
  61.             strRunningUserID = owshNetwork.UserName
  62.             
  63.             call sub_LogMPScriptEvent (4005, "sub_LogMPScriptEvent. Script running as user: " & strRunningUserID , Err, strDebugMode,strMPScriptName,MOMEVENTLOGINFORMATION)
  64.             On error goto 0
  65.             fct_LogRunningAccount = strRunningUserID
  66. End Function
  67. '-----------------------------------------------------------------------------------------------------
  68. private sub sub_LogScriptStartInfo(byRef oArgs, byVal strDebugModeValue, byval strMomLevelEvent, byVal strScriptName)
  69. ' Log an event with the default informations. The event contains :
  70. ' - The account used to run the script
  71. ' - The number of script parameters
  72. ' - The values of the parameters
  73. ' - The value of the debug mode
  74.             Dim owshNetwork
  75.             Dim strLogMessage
  76.             Dim strRunAsAccount
  77.             On Error Resume Next
  78.             Set owshNetwork = WScript.CreateObject("WScript.Network")
  79.             'Assign user name returned to a variable
  80.             strRunAsAccount = owshNetwork.UserName
  81.              strLogMessage=""
  82.             ' Create the start log Script with launch information data RunAs account, debugmode, arguments)
  83.             strLogMessage = vbcrlf & "The script has been launched under following credentials : " &             strRunAsAccount & "." & vbcrlf & vbcrlf & oArgs.count & " arguments have been passed in parameter : "
  84.             For intIndex = 0 To oArgs.Count-1
  85.                         strLogMessage = strLogMessage & vbcrlf & " - " & oArgs(intIndex)
  86.             Next
  87.             strLogMessage = strLogMessage & vbcrlf & vbcrlf & "The debug mode value for the Management Pack is set to : " & strDebugModeValue
  88.             Call oAPI.LogScriptEvent(strScriptName, 10212, strMomLevelEvent, strLogMessage)
  89. End sub
  90. '-----------------------------------------------------------------------------------------------------
 And the next part of the discovery will be the main part that will test the number of arguments and create / read the debugging registry key :
  1. '-----------------------------------------------------------------------------------------------------
  2. ' MAIN CODE START HERE
  3. '-----------------------------------------------------------------------------------------------------
  4. ' Gets the arguments passed in parameters of the script
  5. Set oArgs = Wscript.Arguments
  6. ' If the minimals arguments are not set then we exit the script
  7. if oArgs.Count < 3 Then
  8.    Wscript.Quit -1
  9. End If
  10. ' Check the value of the registry key on the server to know if the debug mode is ON or not
strRegValue = ""
  1. 'By default the registry key is set to : DOES NOT EXIST. See fct_ReadRegistryKey for more information
  2. strRegValue = fct_ReadRegistryKey(REGKEYPATH, strRegKeyName)
  3. 'If the registry key is TRUE XOR FALSE then the debugmodevalue has a good value
  4. If ((strRegValue = "TRUE") Xor (strRegValue = "FALSE")) Then
  5.             strCurrentDebugModeValue = strRegValue
  6. Else
  7.             'If the registry key is empty or not correctly set then a attempt to set to default value is made.
  8.             If fct_WriteRegistryKey(REGKEYPATH, strRegKeyName, REGISTRYDEFVALUE) Then
  9.                         ' write event 10211 that says the registry key has been created
  10.                         call sub_LogMPScriptEvent (10211, "Registry Key " & REGKEYPATH & "\" & strRegKeyName & " With Value = " & REGISTRYDEFVALUE & " has been created", Err, True,strMPScriptName,MOMEVENTLOGINFORMATION)
  11.             Else
  12.                         ' write event 10210 that says the registry key has not been created
  13.                         call sub_LogMPScriptEvent (10210, "Error in creation of the Registry Key " & REGKEYPATH & "\" & strRegKeyName & " With Value = " & REGISTRYDEFVALUE , Err, True,strMPScriptName,MOMEVENTLOGERROR)
  14.             End if
  15.             strCurrentDebugModeValue = REGISTRYDEFVALUE
  16. End if The discovery itself : 'Return Data to the Management PackCall oDiscoveryData.AddInstance(oInst)
Call oAPI.Return(oDiscoveryData)
  1.  
  2. Dim intSourceType
  3. Dim strSourceId0
  4. Dim strTargetComputer
  5. Dim strManagedEntityId
  6. intSourceType =
  7. 'Set the arguments for creating the default Management Pack modules.strSourceId = oArgs(0)
  8. strManagedEntityId = oArgs(1)
  9. strTargetComputer = oArgs(2)
  10. 'Create the default management pack classSet oDiscoveryData = oAPI.CreateDiscoveryData(intSourceType, strSourceId, strManagedEntityId)
  11. Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='MyNewMP.CLS1']$")
  12. call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", strTargetComputer)
  13. call oInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "MyNewMP")
  14. call oInst.AddProperty("$MPElement[Name='MyNewMP.CLS1']/DebugMod$", strCurrentDebugModeValue)
  15.  
  16. call sub_LogMPScriptEvent (10213, "Server "& strTargetComputer & " has been discovered. The debug mode value on this server is set to " & strCurrentDebugModeValue, Err, strCurrentDebugModeValue,strMPScriptName,MOMEVENTLOGINFORMATION)
  17. '-----------------------------------------------------------------------------------------------------
  18. ' PUT YOUR DISCOVERY CODE AFTER
  19. '-----------------------------------------------------------------------------------------------------
  20. 'Return Data to the Management PackCall oDiscoveryData.AddInstance(oInst)
  21. Call oAPI.Return(oDiscoveryData)
'Log the Management Pack default informations with runas account, debugmode and parameters info call sub_LogScriptStartInfo(oArgs, strCurrentDebugModeValue, MOMEVENTLOGINFORMATION, strMPScriptName)



How to use the debugging functionnality will be explained in PART III

End of PART II
Back to Part I                                                                                         Go to Part III


This posting is provided "AS IS" with no warranties.