{"id":3543,"date":"2012-03-16T21:22:27","date_gmt":"2012-03-16T19:22:27","guid":{"rendered":"https:\/\/ingmarverheij.com\/?p=3543"},"modified":"2012-03-16T21:28:05","modified_gmt":"2012-03-16T19:28:05","slug":"opsmgr-prevent-warning-event-21405","status":"publish","type":"post","link":"https:\/\/ingmarverheij.com\/en\/opsmgr-prevent-warning-event-21405\/","title":{"rendered":"OpsMgr: Prevent warning event 21405"},"content":{"rendered":"\n<p><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; float: right; border-top: 0px; border-right: 0px; padding-top: 0px\" title=\"\" border=\"0\" alt=\"\" align=\"right\" src=\"https:\/\/ingmarverheij.com\/wp-content\/uploads\/2012\/03\/OpsMgr-logo.gif\" width=\"119\" height=\"92\" \/><\/p>\n<p>A System Center Operation Manager (SCOM or OpsMgr) management pack might cause warning event with ID 21405. This event is raised when a script is run without returning any data.<\/p>\n<p>&#160;<\/p>\n<p><a href=\"https:\/\/ingmarverheij.com\/wp-content\/uploads\/2012\/03\/EventID-21405.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; margin: 0px 5px 0px 0px; padding-left: 0px; padding-right: 0px; display: inline; float: right; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"\" border=\"0\" alt=\"\" align=\"right\" src=\"https:\/\/ingmarverheij.com\/wp-content\/uploads\/2012\/03\/EventID-21405_thumb.png\" width=\"304\" height=\"213\" \/><\/a><\/p>\n<p><font face=\"Courier New\">Log Name:&#160;&#160;&#160;&#160;&#160; Operations Manager      <br \/>Source:&#160;&#160;&#160;&#160;&#160;&#160;&#160; Health Service Modules       <br \/>Date:&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 16-3-2012 16:14:26       <br \/>Event ID:&#160;&#160;&#160;&#160;&#160; 21405       <br \/>Task Category: None       <br \/>Level:&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Warning       <br \/>Keywords:&#160;&#160;&#160;&#160;&#160; Classic       <br \/>User:&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; N\/A       <br \/>Computer:&#160;&#160;&#160;&#160;&#160; <br \/>Description:       <br \/>The process started at 16:14:26 failed to create System.PropertyBagData, no errors detected in the output.&#160; The process exited with 0       <br \/><\/font><\/p>\n<p>A script is run to discover objects or to query data (to collect data &#8211; a rule &#8211; or to monitor and object &#8211; a monitor) and should return this data to the MOM.ScriptAPI object so it can be processed. If a script is run without returning data OpsMgr suspects an issue. A script might not return data because of <a href=\"https:\/\/blogs.technet.com\/b\/operationsmgr\/archive\/2009\/01\/22\/anti-virus-software-may-cause-script-failures-in-opsmgr-2007.aspx\" target=\"_blank\">antivirus<\/a>, <a href=\"https:\/\/thoughtsonopsmgr.blogspot.com\/2011\/02\/eventid-21405-process-started-at-x.html\" target=\"_blank\">DEP<\/a> or by design. If you design a management pack, continue reading.<\/p>\n<p><!--more--><\/p>\n<h4>By design<\/h4>\n<p>If you expect a script not to return data you need to make sure that OpsMgr is aware of this so you can prevent the 21405 event. The event can be prevented by adding an event policy, as described by <a href=\"https:\/\/rburri.wordpress.com\/2008\/05\/13\/running-timed-script-discovery-without-getting-warning-event-21405\/\" target=\"_blank\">Raphael Burri:<\/a><\/p>\n<p>First of all you need to make sure the script ends gracefully (error code 0)<\/p>\n<pre lang=\"vbscript\">wscript.quit(0)<\/pre>\n<p>Secondly you need to add an event policy at the end of the datasource tag.<\/p>\n<pre lang=\"xml\">&lt;EventPolicy&gt;\n   &lt;!--Do not write Warning Event 21405 (no discovery data) when the script doesn't return any data (product not installed) \u2013&gt;\n   &lt;StdOutMatches&gt;&lt;\/StdOutMatches&gt;\n   &lt;!--Standard Error Out Matches (leave default) \u2013&gt;\n   &lt;StdErrMatches&gt;\\a+&lt;\/StdErrMatches&gt;\n   &lt;!--Exit Code matches (leave default) \u2013&gt;\n   &lt;ExitCodeMatches&gt;[^0]+&lt;\/ExitCodeMatches&gt;\n&lt;\/EventPolicy&gt;<\/pre>\n<p>&#160;<\/p>\n<h4>DiscoveryData<\/h4>\n<p>If you have a script that is used to discover objects and it fails to complete successfully, there is a chance that the objects disappear from OpsMgr. To avoid this you can set the <strong>IsSnapshot<\/strong> property of the <strong>CreateDiscoveryData<\/strong> to True, as described by <a href=\"https:\/\/blogs.msdn.com\/b\/boris_yanushpolsky\/archive\/2008\/12\/19\/what-if-my-discovery-script-fails.aspx\" target=\"_blank\">Boris Yanushpolsky<\/a>. <\/p>\n<p>&#160;<\/p>\n<h4>Error opening management pack<\/h4>\n<p>The first time I tried adding the event policy, as described by <a href=\"https:\/\/rburri.wordpress.com\/2008\/05\/13\/running-timed-script-discovery-without-getting-warning-event-21405\/\" target=\"_blank\">Raphael Burri<\/a>, I got the following error while opening the file in the Authoring Console:<\/p>\n<p><a href=\"https:\/\/ingmarverheij.com\/wp-content\/uploads\/2012\/03\/Error-opening-in-Authoring-Console.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; margin: 0px 5px 0px 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"\" border=\"0\" alt=\"\" src=\"https:\/\/ingmarverheij.com\/wp-content\/uploads\/2012\/03\/Error-opening-in-Authoring-Console_thumb.png\" width=\"554\" height=\"138\" \/><\/a>&#160;<\/p>\n<pre>Date: 3\/16\/2012 8:20:30 PM\nApplication: System Center Operations Manager 2007 R2 Authoring Console\nApplication Version: 6.1.7221.49\nSeverity: Error\nMessage: \n\n: XSD verification failed for management pack. [Line: 135, Position: 18]\nThe element 'DataSourceModuleType' has invalid child element 'EventPolicy'. List of possible elements expected: 'Configuration'.\nSystem.Xml.Schema.XmlSchemaValidationException: The element 'DataSourceModuleType' has invalid child element 'EventPolicy'. List of possible elements expected: 'Configuration'.<\/pre>\n<p>This is because the EventPolicy element isn\u2019t defined properly.<\/p>\n<p>&#160;<\/p>\n<h4>Example: TimedScript.PerformanceProvider<\/h4>\n<p>I\u2019ve got a rule that collect performance data using the <a href=\"https:\/\/64.4.10.24\/en-us\/library\/hh367531.aspx\" target=\"_blank\">Microsoft.Windows.TimedScript.PerformanceProvider<\/a> data source module. I know that the object I\u2019m querying not always return data because it only generates data at certain moment, so I don\u2019t want to return a <a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/bb437537.aspx\" target=\"_blank\">PropertyBag<\/a>.<\/p>\n<p>Before you can add the event policy to a datasource you need to include the <a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/ff400190.aspx\" target=\"_blank\">CommandExecuterSchema<\/a> schema and add a EventPolicy element to the DataSourceModule.<\/p>\n<pre lang=\"xml\">&lt;DataSourceModuleType ID=&quot;Denamik.E2EM.DataSource.Entity&quot; Accessibility=&quot;Internal&quot; Batching=&quot;false&quot;&gt;\n   &lt;Configuration&gt;\n      &lt;IncludeSchemaTypes&gt;\n         &lt;SchemaType&gt;System!System.CommandExecuterSchema&lt;\/SchemaType&gt;\n      &lt;\/IncludeSchemaTypes&gt;\n      &lt;xsd:element minOccurs=&quot;1&quot; name=&quot;IntervalSeconds&quot; type=&quot;xsd:integer&quot; \/&gt;\n      &lt;xsd:element minOccurs=&quot;1&quot; name=&quot;TimeoutSeconds&quot; type=&quot;xsd:integer&quot; \/&gt;\n      &lt;xsd:element minOccurs=&quot;0&quot; maxOccurs=&quot;1&quot; name=&quot;EventPolicy&quot; type=&quot;CommandExecuterEventPolicyType&quot; \/&gt;\n   &lt;\/Configuration&gt;<\/pre>\n<p>Now you can add the event policy to the datasource:<\/p>\n<pre lang=\"xml\">&lt;MemberModules&gt;\n   &lt;DataSource ID=&quot;DS&quot; TypeID=&quot;Windows!Microsoft.Windows.TimedScript.PerformanceProvider&quot;&gt;\n      &lt;IntervalSeconds&gt;$Config\/IntervalSeconds$&lt;\/IntervalSeconds&gt;\n      &lt;SyncTime \/&gt;\n      &lt;ScriptName&gt;(your script name)&lt;\/ScriptName&gt;\n      &lt;Arguments&gt;$Config\/Arguments$&lt;\/Arguments&gt;\n      &lt;ScriptBody&gt;(your script)&lt;\/ScriptBody&gt;\n      &lt;TimeoutSeconds&gt;$Config\/TimeoutSeconds$&lt;\/TimeoutSeconds&gt;\n      &lt;EventPolicy&gt;\n         &lt;StdOutMatches \/&gt;\n         &lt;StdErrMatches&gt;\\a+&lt;\/StdErrMatches&gt;\n         &lt;ExitCodeMatches&gt;[^0]+&lt;\/ExitCodeMatches&gt;\n      &lt;\/EventPolicy&gt;\n      &lt;ObjectName&gt;$Data\/Property[@Name='Object']$&lt;\/ObjectName&gt;\n      &lt;CounterName&gt;$Data\/Property[@Name='Counter']$&lt;\/CounterName&gt;\n      &lt;InstanceName&gt;$Data\/Property[@Name='Instance']$&lt;\/InstanceName&gt;\n      &lt;Value&gt;$Data\/Property[@Name='Value']$&lt;\/Value&gt;\n   &lt;\/DataSource&gt;\n&lt;\/MemberModules&gt;<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>A System Center Operation Manager (SCOM or OpsMgr) management pack might cause warning event with ID 21405. This event is raised when a script is run without returning any data. &#160; Log Name:&#160;&#160;&#160;&#160;&#160; Operations Manager Source:&#160;&#160;&#160;&#160;&#160;&#160;&#160; Health Service Modules Date:&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 16-3-2012 16:14:26 Event ID:&#160;&#160;&#160;&#160;&#160; 21405 Task Category: None Level:&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Warning Keywords:&#160;&#160;&#160;&#160;&#160; Classic User:&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; N\/A Computer:&#160;&#160;&#160;&#160;&#160; [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-container-style":"default","site-container-layout":"default","site-sidebar-layout":"default","disable-article-header":"default","disable-site-header":"default","disable-site-footer":"default","disable-content-area-spacing":"default","footnotes":""},"categories":[311],"tags":[432,431,433,235],"class_list":["post-3543","post","type-post","status-publish","format-standard","hentry","category-system-center-operations-manager-scom","tag-discoverydata","tag-opsmgr","tag-performanceprovider","tag-scom"],"_links":{"self":[{"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/posts\/3543","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/comments?post=3543"}],"version-history":[{"count":4,"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/posts\/3543\/revisions"}],"predecessor-version":[{"id":3548,"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/posts\/3543\/revisions\/3548"}],"wp:attachment":[{"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/media?parent=3543"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/categories?post=3543"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/tags?post=3543"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}