<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>cchamp's opsmgr blog</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/cchamp/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/cchamp/feed.xml</link>
    <description />
    <lastBuildDate>Wed, 17 Apr 2019 03:30:04 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Loading the SCOM PowerShell Module, For Real This Time!</title>
      <link>https://docs.microsoft.com/archive/blogs/cchamp/loading-the-scom-powershell-module-for-real-this-time</link>
      <pubDate>Wed, 30 Sep 2015 08:29:47 GMT</pubDate>
      <dc:creator><![CDATA[cchamp]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/cchamp/2015/09/30/loading-the-scom-powershell-module-for-real-this-time/</guid>
      <description><![CDATA[This is just a quick post and reference for how I have come to load the SCOM PowerShell module for...]]></description>
      <content:encoded><![CDATA[<p>This is just a quick post and reference for how I have come to load the SCOM PowerShell module for scripts that requiring SCOM cmdlets. It evolved from several examples I borrowed (thank you to those sources which I&#39;ve since lost), combined with some real world experiences (such as running inside a SCOM rule / PowerShell Workspace API, running from Orchestrator, running from a scheduled task, running from a machine with the console and PS module install but not a MS), and is now:<br /></p><pre><font color="#ff4500"><font style="font-size:9pt;" size="2">$OMCmdletsTest</font></font><font style="font-size:9pt;" size="2"></font><font color="#a9a9a9"><font style="font-size:9pt;" size="2"> = </font></font><font style="font-size:9pt;" size="2">(</font><font color="#0000ff"><font style="font-size:9pt;" size="2">Get-Module</font></font><font color="#a9a9a9"><font style="font-size:9pt;" size="2">|</font></font><font color="#0000ff"><font style="font-size:9pt;" size="2">%</font></font><font style="font-size:9pt;" size="2"> {</font><font color="#ff4500"><font style="font-size:9pt;" size="2">$_</font></font><font color="#a9a9a9"><font style="font-size:9pt;" size="2">.</font></font><font style="font-size:9pt;" size="2">Name})</font><font color="#a9a9a9"><font style="font-size:9pt;" size="2"> -Join </font></font><font style="font-size:9pt;" size="2"></font><font color="#8b0000"><font style="font-size:9pt;" size="2">&#39; &#39;</font></font>
<font color="#00008b"><font style="font-size:9pt;" size="2">If </font></font><font style="font-size:9pt;" size="2">(</font><font color="#a9a9a9"><font style="font-size:9pt;" size="2">!</font></font><font color="#ff4500"><font style="font-size:9pt;" size="2">$OMCmdletsTest</font></font><font color="#a9a9a9"><font style="font-size:9pt;" size="2">.</font></font><font style="font-size:9pt;" size="2">Contains(</font><font color="#8b0000"><font style="font-size:9pt;" size="2">&#39;OperationsManager&#39;</font></font><font style="font-size:9pt;" size="2">)) {</font>
    <font color="#ff4500"><font style="font-size:9pt;" size="2">$ModuleFound</font></font><font style="font-size:9pt;" size="2"></font><font color="#a9a9a9"><font style="font-size:9pt;" size="2"> = </font></font><font style="font-size:9pt;" size="2"></font><font color="#ff4500"><font style="font-size:9pt;" size="2">$false</font></font>
    <font color="#ff4500"><font style="font-size:9pt;" size="2">$SetupKeys</font></font><font style="font-size:9pt;" size="2"></font><font color="#a9a9a9"><font style="font-size:9pt;" size="2"> = </font></font><font style="font-size:9pt;" size="2">@(</font><font color="#8b0000"><font style="font-size:9pt;" size="2">&#39;HKLM:\Software\Microsoft\Microsoft Operations Manager\3.0\Setup&#39;</font></font><font color="#a9a9a9"><font style="font-size:9pt;" size="2">,</font></font>       
        <font color="#8b0000"><font style="font-size:9pt;" size="2">&#39;HKLM:\SOFTWARE\Microsoft\System Center Operations Manager\12\Setup&#39;</font></font><font style="font-size:9pt;" size="2">)</font>
    <font color="#00008b"><font style="font-size:9pt;" size="2">foreach</font></font><font style="font-size:9pt;" size="2">(</font><font color="#ff4500"><font style="font-size:9pt;" size="2">$setupKey</font></font><font style="font-size:9pt;" size="2"></font><font color="#00008b"><font style="font-size:9pt;" size="2"> in </font></font><font style="font-size:9pt;" size="2"></font><font color="#ff4500"><font style="font-size:9pt;" size="2">$SetupKeys</font></font><font style="font-size:9pt;" size="2">) {</font>
        <font color="#00008b"><font style="font-size:9pt;" size="2">If </font></font><font style="font-size:9pt;" size="2">(<font style="font-size:9pt;" size="2">(</font></font><font color="#0000ff"><font style="font-size:9pt;" size="2">Test-Path </font></font><font style="font-size:9pt;" size="2"></font><font color="#ff4500"><font style="font-size:9pt;" size="2">$setupKey</font></font><font color="#000080"><font style="font-size:9pt;" size="2"><font style="font-size:9pt;" size="2"><font color="#000000">)</font> </font>-and <font style="font-size:9pt;" color="#000000" size="2">(</font></font></font><font style="font-size:9pt;" size="2"></font><font color="#ff4500"><font style="font-size:9pt;" size="2">$ModuleFound</font></font><font style="font-size:9pt;" size="2"></font><font color="#000080"><font style="font-size:9pt;" size="2"> -eq </font></font><font style="font-size:9pt;" size="2"></font><font color="#ff4500"><font style="font-size:9pt;" size="2">$false</font></font><font style="font-size:9pt;" size="2"><font style="font-size:9pt;" size="2">)<font style="font-size:9pt;" size="2">)</font></font> {</font>
            <font color="#ff4500"><font style="font-size:9pt;" size="2">$setupKey</font></font><font style="font-size:9pt;" size="2"></font><font color="#a9a9a9"><font style="font-size:9pt;" size="2"> = </font></font><font style="font-size:9pt;" size="2"></font><font color="#0000ff"><font style="font-size:9pt;" size="2">Get-Item</font></font><font style="font-size:9pt;" size="2"></font><font color="#000080"><font style="font-size:9pt;" size="2"> -Path </font></font><font style="font-size:9pt;" size="2"></font><font color="#ff4500"><font style="font-size:9pt;" size="2">$setupKey</font></font>           
            <font color="#ff4500"><font style="font-size:9pt;" size="2">$installDirectory</font></font><font color="#a9a9a9"><font style="font-size:9pt;" size="2"> = </font></font><font color="#ff4500"><font style="font-size:9pt;" size="2">$setupKey</font></font><font color="#a9a9a9"><font style="font-size:9pt;" size="2">.</font></font><font style="font-size:9pt;" size="2">GetValue(</font><font color="#8b0000"><font style="font-size:9pt;" size="2">&#39;InstallDirectory&#39;</font></font><font style="font-size:9pt;" size="2">)</font>
            <font color="#ff4500"><font style="font-size:9pt;" size="2">$psmPath</font></font><font color="#a9a9a9"><font style="font-size:9pt;" size="2"> = </font></font><font color="#ff4500"><font style="font-size:9pt;" size="2">$installdirectory</font></font><font color="#a9a9a9"><font style="font-size:9pt;" size="2"> + </font></font><font color="#8b0000"><font style="font-size:9pt;" size="2">&#39;\Powershell\OperationsManager\OperationsManager.psm1&#39;</font></font>
            <font color="#00008b"><font style="font-size:9pt;" size="2">If </font></font><font style="font-size:9pt;" size="2">(</font><font color="#0000ff"><font style="font-size:9pt;" size="2">Test-Path </font></font><font style="font-size:9pt;" size="2"></font><font color="#ff4500"><font style="font-size:9pt;" size="2">$psmPath</font></font><font style="font-size:9pt;" size="2">) {</font>
                <font color="#ff4500"><font style="font-size:9pt;" size="2">$ModuleFound</font></font><font color="#a9a9a9"><font style="font-size:9pt;" size="2"> = </font></font><font color="#ff4500"><font style="font-size:9pt;" size="2">$true</font></font>
            <font style="font-size:9pt;" size="2">}</font>
        <font style="font-size:9pt;" size="2">}</font>
    <font style="font-size:9pt;" size="2">}</font>
    <font color="#00008b"><font style="font-size:9pt;" size="2">If </font></font><font style="font-size:9pt;" size="2">(</font><font color="#ff4500"><font style="font-size:9pt;" size="2">$ModuleFound</font></font><font style="font-size:9pt;" size="2">) {</font>
        <font color="#0000ff"><font style="font-size:9pt;" size="2">Import-Module</font></font><font style="font-size:9pt;" size="2"></font><font color="#ff4500"><font style="font-size:9pt;" size="2"> $psmPath</font></font>
    <font style="font-size:9pt;" size="2">} </font><font color="#00008b"><font style="font-size:9pt;" size="2">else</font></font><font style="font-size:9pt;" size="2"> {</font>
        <font color="#0000ff"><font style="font-size:9pt;" size="2">Import-Module</font></font><font style="font-size:9pt;" size="2"></font><font color="#8a2be2"><font style="font-size:9pt;" size="2"> OperationsManager</font></font>
    <font style="font-size:9pt;" size="2">}</font>
<font style="font-size:9pt;" size="2">}</font>
</pre>]]></content:encoded>
    </item>
    <item>
      <title>Multi-home Management Group Automation MP</title>
      <link>https://docs.microsoft.com/archive/blogs/cchamp/multi-home-management-group-automation-mp</link>
      <pubDate>Tue, 08 Sep 2015 22:15:04 GMT</pubDate>
      <dc:creator><![CDATA[cchamp]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/cchamp/2015/09/08/multi-home-management-group-automation-mp/</guid>
      <description><![CDATA[&nbsp; Hello, just fulfilling a quick ask with this one. With SCOM 2012 we were given the ability to...]]></description>
      <content:encoded><![CDATA[<p>&nbsp;</p> <p>Hello, just fulfilling a quick ask with this one. With SCOM 2012 we were given the ability to manage agent Management Group configuration using the Agent Config Manager Object or AgentConfigManager.MgmtSvcCfg. It can be leveraged in VBS or PowerShell to Add, Remove, and List SCOM management groups configured on the agent. This isn’t groundbreaking news and the methods are well documented, and plenty of community examples exists already.</p> <p>That said, I see it asked frequently about what the best method of running a script to modify MG settings against their agent install base. SCCM and remote PowerShell are common solutions, but with this last go-around, I thought why not leverage SCOM itself (assuming it’s not an all-out removal).</p> <p>Below is a link to a VSAE project for a Management Pack that contains two disabled rules and a script-based data source (VBS) to help automate the addition and removal of management groups for agents. The rules can be overridden and enabled to Add a MG w/a Management Server, or remove a MG.</p> <p>I’ve done my best to include logging and protections against bad things (like removing the last MG on an agent), but please be cautious as this MP could be dangerous and easily break every agent. As always:</p> <p><strong>This is provided AS-IS, as an example only, and contains no warranty. The MP should not be used in a production environment without careful review and planning.</strong></p> <p>Have fun!</p> <p><a title="https://github.com/cchamp-msft/MultiHome.ManagementGroup.Automator" href="https://github.com/cchamp-msft/MultiHome.ManagementGroup.Automator">https://github.com/cchamp-msft/MultiHome.ManagementGroup.Automator</a></p>]]></content:encoded>
    </item>
    <item>
      <title>Sky Blue–How to keep monitors from going unnoticed after closing an alert</title>
      <link>https://docs.microsoft.com/archive/blogs/cchamp/sky-bluehow-to-keep-monitors-from-going-unnoticed-after-closing-an-alert</link>
      <pubDate>Mon, 17 Aug 2015 22:41:18 GMT</pubDate>
      <dc:creator><![CDATA[cchamp]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/cchamp/2015/08/17/sky-bluehow-to-keep-monitors-from-going-unnoticed-after-closing-an-alert/</guid>
      <description><![CDATA[Scenario: A 3-state logical disk monitor targets a disk that meets the warning threshold. A warning...]]></description>
      <content:encoded><![CDATA[<p>Scenario: A 3-state logical disk monitor targets a disk that meets the warning threshold. A warning alert is raised.  <p>The Operations Team sees the alerts, consults SOP guidance which states ignore warnings, and manually closes the alert. The alert is gone, but the underlying monitor is still unhealthy with a state of warning. A day later the disk space used is now critical, and the monitor state changes to match.  <p>The problem is the alert is closed and it won’t fire again until the monitor is healthy.  <p>The critical alert is closed. Operations doesn’t look at closed alerts. And so the disk reaches capacity, potentially bad things happen, and ultimately someone asks, “Why didn’t we get an alert?”  <p>Well we did, and we closed it.  <p>Let’s consider how alerts are generated from monitors. We often speak in terms of an alert being generated when a threshold is met, and in the case of monitors that over simplifies the process and leaves out an important step. The thresholds trigger a condition detection path that leads to a state change. That state change can then prompt for an alert to be generated. In the case of 3-state monitors, we only generate one alert. When we change from a warning to a critical state, alert severity can be (and often is) configured to match the monitor state. The not so intuitive part of this model reveals itself in that when an operator sees a non-actionable alert, the default behavior is to close the alert. Closing the alert does not affect the state of the monitor. That’s when we find ourselves in situations where the state of a monitor can be warning or critical, but we have no corresponding alert. The state changed so long ago, the alert has been groomed after someone closed it.  <p>So how do we avoid these situations?  <p>Well, first we can always submit product feedback, such as something like:  <p><a href="https://systemcenterom.uservoice.com/forums/293064-general-operations-manager-feedback/suggestions/9356712-a-way-to-reset-monitors-automatically-when-alert-I">https://systemcenterom.uservoice.com/forums/293064-general-operations-manager-feedback/suggestions/9356712-a-way-to-reset-monitors-automatically-when-alert-I</a>  <p>But until then we can address the behavior with a PowerShell driven Management Pack I created called Sky Blue. Thanks to Peter Lem for the name, a play on <a href="https://blogs.technet.com/b/timhe/archive/2014/07/25/greenmachine-2012.aspx">Green Machine</a> and the fact that management asking about “missing alerts” always feels like a rainy day.  <p>Now the ask in the above feedback link is somewhat different than an ask I had from a customer which originally drove this workaround. Instead of providing a task or a way to replicate Green Machine’s resetting of monitor states, the approach with Sky Blue is to enforce good operator behavior in the SCOM console. Sky Blue protects against accidental alert closures by re-opening closed alerts where the monitor state is not healthy. This is done via a rule that runs every five minutes (override-able) against the All MS Resource Pool. The rule runs a PowerShell script that queries for all closed alerts within the past two intervals that were generated by a monitor, checks the state of those monitors, and re-opens (sets state to 0) any alert where the monitor state is not healthy and not in maintenance mode.  <p>Or more specifically, albeit condensed:  <p>$interval=300<br />$d=(Get-Date).ToUniversalTime().AddSeconds($interval*-2)<br />$alerts=(Get-SCOMAlert -Criteria &quot;ResolutionState = 255 And LastModified &gt; &#39;$d&#39; And IsMonitorAlert = &#39;True&#39; And MonitoringObjectHealthState &lt;&gt; 1&quot; | Sort-Object -Descending TimeRaised)<br />foreach ($alert in $alerts) {<br />&nbsp;&nbsp;&nbsp; $alertCheck = Get-SCOMAlert -Criteria &quot;ResolutionState &lt;&gt; 255 And IsMonitorAlert = &#39;True&#39; And RuleId = &#39;$($alert.RuleId)&#39; And MonitoringObjectId = &#39;$($alert.MonitoringObjectId)&#39;&quot;<br />&nbsp;&nbsp;&nbsp; if ($alertCheck.Count -eq 0) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $alert.ResolutionState = 0<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $alert.Update(&#39;Sky Blue found a closed alert from a monitor that is not healthy. Changing Resolution State to New.&#39;)<br />&nbsp;&nbsp;&nbsp; }<br />}  <p>Better yet, head over to GitHub for the whole VSAE project with the PowerShell wrapped up in a rule with a scheduler. Pull Requests and feedback welcome.<br /><a href="https://github.com/cchamp-msft/SkyBlue">https://github.com/cchamp-msft/SkyBlue</a>  <p>Or if you want an unsealed copy of the built MP:<br /><a href="https://github.com/cchamp-msft/SkyBlue/blob/master/SkyBlue/bin/Release/SkyBlue.xml">https://github.com/cchamp-msft/SkyBlue/blob/master/SkyBlue/bin/Release/SkyBlue.xml</a> </p> <p>The configuration of the rule is as follows:</p> <ul> <li>IntervalSeconds – Default 300 – How often to run the rule (300 is fairly aggressive, 3600 is still effective).</li> <li>NoReopenSeconds – Default 0 – Useful for sub 60 second interval so that it won’t re-open anything that auto-closed before the monitor has fully reconciled. This setting is not for production use, but if I recall correctly I set this to 30 when testing on a 30 second interval.</li> <li>TimeoutSeconds – Default 60 – Timeout for the PowerShell script, 60 should suffice.</li> <li>GenerateAlert – Default true – Whether or not to generate an alert on error condition</li> <li>Debug – Default false – Whether or not to make a mess of the Operations Manager event log on the MS running the rule in the All MS Resource Pool.</li></ul> <p>Please note this is provided as-is and contains no warranty. Thank you <a href="https://www.opsconfig.com/">Michael Bullwinkle</a> for kindly reviewing and editing this post.</p></p></p></p></p></p></p></p></p></p></p></p></p></p></p>]]></content:encoded>
    </item>
    <item>
      <title>Authoring with Azure Run As Certificate Credentials</title>
      <link>https://docs.microsoft.com/archive/blogs/cchamp/authoring-with-azure-run-as-certificate-credentials</link>
      <pubDate>Thu, 16 Apr 2015 22:07:00 GMT</pubDate>
      <dc:creator><![CDATA[cchamp]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/cchamp/2015/04/16/authoring-with-azure-run-as-certificate-credentials/</guid>
      <description><![CDATA[As Azure becomes more prominent, I’m running into more asks on how monitor Azure from an on-premises...]]></description>
      <content:encoded><![CDATA[<p><br /><font size="2">As Azure becomes more prominent, I’m running into more asks on how monitor Azure from an on-premises perspective. As of this writing, we have a couple management packs available now that can help with this. One that monitors cloud services (VMs and storage), and it also discovers the presence of SQL Azure—</font><a href="https://www.microsoft.com/en-us/download/details.aspx?id=38414"><font size="2">System Center Management Pack for Windows Azure</font></a><font size="2"> v1.1.238.0, 10/2/2014. And another for specifically monitoring SQL Azure databases—</font><a href="https://www.microsoft.com/en-us/download/details.aspx?id=38829"><font size="2">Windows Azure SQL Database Management Pack</font></a><font size="2"> v1.5.4.0, 5/7/2013. There’s an older one out there as well, but that’s out of the scope of this post. Those are great, but they don’t cover everything as of yet. In the meantime, as per the guide for the Windows Azure MP says, any other gaps in monitoring need to be addressed by “[using] MP Authoring tools to create additional collection rules and monitors.” Sounds trivial enough…</font></p> <p><font size="2">When considering what’s involved with monitoring Azure, there are two major requirements: How to connect to Azure, and how to authenticate to Azure. The way the Windows Azure MP deals with the first is through a custom resource DLL included in the MPB file. The DLL contains functions that the MP leverages via Data Sources to feed the discoveries and monitoring workflows. While this is great for what’s provided and likely offers better performance at scale, it doesn’t offer much in terms of extensibility for Azure features outside the scope of the DLL. For any custom monitoring, I much rather rely on <a href="https://azure.microsoft.com/en-us/documentation/articles/powershell-install-configure/">Azure PowerShell</a>. If you’re already acquainted, great! If not, check it out, connect it to your subscription and poke around.</font></p> <p><font size="2">The first step in working with Azure PowerShell highlights the the other hurdle—authentication. Azure PowerShell typically uses a subscription registered with <a href="https://msdn.microsoft.com/en-us/library/dn722528.aspx">Add-AzureAccount</a>, an interactive process that presents a windowed browser for logging in. Since interactive isn’t choice for automating or embedding in a terminal-less workflow, <a href="https://msdn.microsoft.com/en-us/library/dn722501.aspx">Set-AzureSubscription</a> gives up a better method for automating the authentication to Azure using a <a href="https://msdn.microsoft.com/en-us/library/azure/gg551722.aspx">management certificate</a>. And so the sub-challenge of where to keep the management certificate presents itself. It is entirely possible to manually (or automatically for matter) deploy the certificate to the Personal Store, and then hardcode the private key in a custom management pack. Or, we can re-purpose…</font></p> <p><font size="2">The Windows Azure MP manages authentication through three Run As Profiles that it’s able to configure based on the responses entered into the Administration-&gt;Windows Azure-&gt;Add and Edit Subscription wizards. The three profiles are the certificate blob (a double-base64 encoded copy of the certificate), the certificate password (used to decrypt the private key), and the credentials to use with the proxy for the subscription. Or by their element IDs:</font></p> <p><font face="Courier New">Microsoft.SystemCenter.WindowsAzure.RunAsProfile.Blob<br /></font><font face="Courier New">Microsoft.SystemCenter.WindowsAzure.RunAsProfile.Password<br /></font><font face="Courier New">Microsoft.SystemCenter.WindowsAzure.RunAsProfile.Proxy</font></p> <p><font size="2">It took a little reverse engineering to figure how to leverage these in a PowerShell workflow within SCOM, mainly due to trying to figure out the format of the certificate. Here’s the PowerShell from my SCOM discovery that I was able to come up with during testing:</font>  <p><font face="Courier New"># define certificate blob from run as profile <br />$CertBlob=&#39;$RunAs[Name=&quot;WindowsAzure!Microsoft.SystemCenter.WindowsAzure.RunAsProfile.Blob&quot;]/Data$&#39;<br />$CertPassword=&#39;$RunAs[Name=&quot;WindowsAzure!Microsoft.SystemCenter.WindowsAzure.RunAsProfile.Password&quot;]/Password$&#39;<br />$AzureSubId=&#39;$Target/Property[Type=&quot;WindowsAzure!Microsoft.SystemCenter.WindowsAzure.Subscription&quot;]/SubscriptionId$&#39;<br />$AzureSubName=&#39;$Target/Property[Type=&quot;System!System.Entity&quot;]/DisplayName$&#39; <br /><br /># decode certificate blob from run as profile <br />$tempBytes=[System.Convert]::FromBase64String($CertBlob) # once<br />$tempString=[System.Text.Encoding]::Unicode.GetString($tempBytes) <br />$tempBytes=[System.Convert]::FromBase64String($tempString) # twice<br />$AzureCert=New-Object System.Security.Cryptography.X509Certificates.X509Certificate2 $AzureCert.Import($tempBytes,$CertPassword,[System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]::MachineKeySet)</font> </p> <p>* Sorry for the word-wrap. I’ve done my best to ensure these copy out correctly.  <p><font size="2">And now there is a x509 certificate object $AzureCert that we can provide to Set-Azuresubscription:</font>  <p><font face="Courier New">Set-AzureSubscription -SubscriptionId $AzureSubId -Certificate $AzureCert -SubscriptionName $AzureSubId<br />Select-AzureSubscription -Current $AzureSubId</font>  <p><font size="2">As for the proxy, Azure PowerShell uses the user or system’s proxy settings. To determine the proxy settings and user context the Windows Azure MP stores the proxy address as a property of the Azure Subscription and the Run As Profile associates to a Run As account that the data source will run as and authenticate (via negotiate presumably) to the proxy as. If no Run As Account is associated, the Default Action Account will be used. If the proxy doesn’t require authentication, then the below example will still work. Make sure to include this in any DataSourceType (WindowsAzure! reference assuming):</font>  <p><font face="Courier New">RunAs=&quot;WindowsAzure!Microsoft.SystemCenter.WindowsAzure.RunAsProfile.Proxy&quot;</font>  <p><font size="2">Then to use the proxy settings in PowerShell, thanks to several examples found on the Internet ultimately culminating to:</font>  <p>$webproxy = &quot;$Target/Property[Type=&quot;WindowsAzure!Microsoft.SystemCenter.WindowsAzure.Subscription&quot;]/ProxyServerAddress$&quot;<br />if ($webproxy -notmatch &quot;^<a href="https://&quot;)">https://&quot;)</a> { $webproxy = &quot;<a href="https://&quot;">https://&quot;</a> + $webproxy }<br />$proxy = new-object System.Net.WebProxy<br />$proxy.Address = $webproxy<br />$proxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials<br />[System.Net.WebRequest]::DefaultWebProxy = $proxy<br /><font size="2"></font></p> <p><font size="2">And believe it or not Azure requests will be sent via the proxy. Next, we need some discovery data. I created a class name Azure.WebApp, and here’s the discovery bag script:</font></p> <p><font face="Courier New">[string]$SourceId = &quot;$Config/SourceId$&quot;<br />[string]$ManagedEntityId=&quot;$Config/ManagedEntityId$&quot;<br />$api = New-Object -ComObject ‘MOM.ScriptAPI’<br />$discoveryData = $api.CreateDiscoveryData(0, $SourceId, $ManagedEntityId)<br /><br />foreach ($Website in Get-AzureWebsite) {<br />&nbsp;&nbsp;&nbsp; $Instance = $discoveryData.CreateClassInstance(&quot;$MPElement[Name=&#39;Azure.WebApp&#39;]$&quot;)<br />&nbsp;&nbsp;&nbsp; $Instance.AddProperty(&quot;$MPElement[Name=&#39;System!System.Entity&#39;]/DisplayName$&quot;, $Website.Name)<br />&nbsp;&nbsp;&nbsp; $Instance.AddProperty(&quot;$MPElement[Name=&#39;Azure.WebApp&#39;]/Enabled$&quot;, $Website.Enabled)<br />&nbsp;&nbsp;&nbsp; $Instance.AddProperty(&quot;$MPElement[Name=&#39;Azure.WebApp&#39;]/State$&quot;, $Website.State.ToString())<br />&nbsp;&nbsp;&nbsp; $Instance.AddProperty(&quot;$MPElement[Name=&#39;Azure.WebApp&#39;]/UsageState$&quot;, $Website.UsageState.ToString())<br />&nbsp;&nbsp;&nbsp; $Instance.AddProperty(&quot;$MPElement[Name=&#39;Azure.WebApp&#39;]/HostNames$&quot;, $Website.HostNames -join &#39;;&#39;)<br />&nbsp;&nbsp;&nbsp; $Instance.AddProperty(&quot;$MPElement[Name=&#39;Azure.WebApp&#39;]/EnabledHostNames$&quot;, $Website.EnabledHostNames -join &#39;;&#39;)<br />&nbsp;&nbsp;&nbsp; $Instance.AddProperty(&quot;$MPElement[Name=&#39;Azure.WebApp&#39;]/AdminEnabled$&quot;, $Website.AdminEnabled)<br />&nbsp;&nbsp;&nbsp; $Instance.AddProperty(&quot;$MPElement[Name=&#39;Azure.WebApp&#39;]/Sku$&quot;, $Website.Sku.ToString())<br />&nbsp;&nbsp;&nbsp; $Instance.AddProperty(&quot;$MPElement[Name=&#39;Azure.WebApp&#39;]/RepositorySiteName$&quot;, $Website.RepositorySiteName)<br />&nbsp;&nbsp;&nbsp; $Instance.AddProperty(&quot;$MPElement[Name=&#39;Azure.WebApp&#39;]/RepositoryUri$&quot;, $(($Website.SiteProperties.Properties | ? {$_.Name -eq &quot;RepositoryUri&quot;}).Value))<br />&nbsp;&nbsp;&nbsp; $Instance.AddProperty(&quot;$MPElement[Name=&#39;Azure.WebApp&#39;]/WebSpace$&quot;, $Website.WebSpace)<br />&nbsp;&nbsp;&nbsp; $discoveryData.AddInstance($Instance)<br />}</font></p> <p><font face="Courier New">$api.Return($discoveryData)&nbsp; <br />#$discoveryData</font></p><font size="2"></font> <p><br /><font size="2">Note the return—$api.Return($discoveryData) instead of the commented #$discoveryData. I use that because instead of using the “native” Microsoft.Windows.PowerShellDiscoveryProbe, I call powershell.exe with System.CommandExecuterProbePropertyBagBase instead (you’ll see several of the newer MPs doing this too). The reason to call out to powershell.exe instead of using the native module is that native module is using a PowerShell Workspace locked in at host version 2.0 and <a href="https://social.technet.microsoft.com/Forums/en-US/d0431d3f-52c3-41b4-be37-7c192e28a62a/powershell-azure-cmdlet-error?forum=scogeneral">Azure PowerShell requires 3.0</a>.</font></p> <p><font size="2">Altogether my current class type and data source type for the discovery looks like (note the hosting relationship with the subscription class):</font></p> <p>&lt;EntityTypes&gt;<br />&nbsp; &lt;ClassTypes&gt;<br />&nbsp;&nbsp;&nbsp; &lt;ClassType ID=&quot;Azure.WebApp&quot; Accessibility=&quot;Public&quot; Abstract=&quot;false&quot; Base=&quot;Windows!Microsoft.Windows.ApplicationComponent&quot; Hosted=&quot;true&quot; Singleton=&quot;false&quot; Extension=&quot;false&quot;&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Property ID=&quot;Enabled&quot; Type=&quot;string&quot; AutoIncrement=&quot;false&quot; Key=&quot;false&quot; CaseSensitive=&quot;false&quot; MaxLength=&quot;256&quot; MinLength=&quot;0&quot; Required=&quot;false&quot; Scale=&quot;0&quot; /&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Property ID=&quot;State&quot; Type=&quot;string&quot; AutoIncrement=&quot;false&quot; Key=&quot;false&quot; CaseSensitive=&quot;false&quot; MaxLength=&quot;256&quot; MinLength=&quot;0&quot; Required=&quot;false&quot; Scale=&quot;0&quot; /&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Property ID=&quot;UsageState&quot; Type=&quot;string&quot; AutoIncrement=&quot;false&quot; Key=&quot;false&quot; CaseSensitive=&quot;false&quot; MaxLength=&quot;256&quot; MinLength=&quot;0&quot; Required=&quot;false&quot; Scale=&quot;0&quot; /&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Property ID=&quot;HostNames&quot; Type=&quot;string&quot; AutoIncrement=&quot;false&quot; Key=&quot;false&quot; CaseSensitive=&quot;false&quot; MaxLength=&quot;256&quot; MinLength=&quot;0&quot; Required=&quot;false&quot; Scale=&quot;0&quot; /&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Property ID=&quot;EnabledHostNames&quot; Type=&quot;string&quot; AutoIncrement=&quot;false&quot; Key=&quot;false&quot; CaseSensitive=&quot;false&quot; MaxLength=&quot;256&quot; MinLength=&quot;0&quot; Required=&quot;false&quot; Scale=&quot;0&quot; /&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Property ID=&quot;AdminEnabled&quot; Type=&quot;string&quot; AutoIncrement=&quot;false&quot; Key=&quot;false&quot; CaseSensitive=&quot;false&quot; MaxLength=&quot;256&quot; MinLength=&quot;0&quot; Required=&quot;false&quot; Scale=&quot;0&quot; /&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Property ID=&quot;Sku&quot; Type=&quot;string&quot; AutoIncrement=&quot;false&quot; Key=&quot;false&quot; CaseSensitive=&quot;false&quot; MaxLength=&quot;256&quot; MinLength=&quot;0&quot; Required=&quot;false&quot; Scale=&quot;0&quot; /&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Property ID=&quot;RepositorySiteName&quot; Type=&quot;string&quot; AutoIncrement=&quot;false&quot; Key=&quot;true&quot; CaseSensitive=&quot;false&quot; MaxLength=&quot;256&quot; MinLength=&quot;0&quot; Required=&quot;false&quot; Scale=&quot;0&quot; /&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Property ID=&quot;RepositoryUri&quot; Type=&quot;string&quot; AutoIncrement=&quot;false&quot; Key=&quot;false&quot; CaseSensitive=&quot;false&quot; MaxLength=&quot;256&quot; MinLength=&quot;0&quot; Required=&quot;false&quot; Scale=&quot;0&quot; /&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Property ID=&quot;WebSpace&quot; Type=&quot;string&quot; AutoIncrement=&quot;false&quot; Key=&quot;false&quot; CaseSensitive=&quot;false&quot; MaxLength=&quot;256&quot; MinLength=&quot;0&quot; Required=&quot;false&quot; Scale=&quot;0&quot; /&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Property ID=&quot;URL&quot; Type=&quot;string&quot; AutoIncrement=&quot;false&quot; Key=&quot;false&quot; CaseSensitive=&quot;false&quot; MaxLength=&quot;256&quot; MinLength=&quot;0&quot; Required=&quot;false&quot; Scale=&quot;0&quot; /&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Property ID=&quot;NumberOfWorkers&quot; Type=&quot;string&quot; AutoIncrement=&quot;false&quot; Key=&quot;false&quot; CaseSensitive=&quot;false&quot; MaxLength=&quot;256&quot; MinLength=&quot;0&quot; Required=&quot;false&quot; Scale=&quot;0&quot; /&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Property ID=&quot;WebSocketsEnabled&quot; Type=&quot;string&quot; AutoIncrement=&quot;false&quot; Key=&quot;false&quot; CaseSensitive=&quot;false&quot; MaxLength=&quot;256&quot; MinLength=&quot;0&quot; Required=&quot;false&quot; Scale=&quot;0&quot; /&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Property ID=&quot;Use32BitWorkerProcess&quot; Type=&quot;string&quot; AutoIncrement=&quot;false&quot; Key=&quot;false&quot; CaseSensitive=&quot;false&quot; MaxLength=&quot;256&quot; MinLength=&quot;0&quot; Required=&quot;false&quot; Scale=&quot;0&quot; /&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Property ID=&quot;DefaultDocuments&quot; Type=&quot;string&quot; AutoIncrement=&quot;false&quot; Key=&quot;false&quot; CaseSensitive=&quot;false&quot; MaxLength=&quot;256&quot; MinLength=&quot;0&quot; Required=&quot;false&quot; Scale=&quot;0&quot; /&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Property ID=&quot;NetFrameworkVersion&quot; Type=&quot;string&quot; AutoIncrement=&quot;false&quot; Key=&quot;false&quot; CaseSensitive=&quot;false&quot; MaxLength=&quot;256&quot; MinLength=&quot;0&quot; Required=&quot;false&quot; Scale=&quot;0&quot; /&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Property ID=&quot;PhpVersion&quot; Type=&quot;string&quot; AutoIncrement=&quot;false&quot; Key=&quot;false&quot; CaseSensitive=&quot;false&quot; MaxLength=&quot;256&quot; MinLength=&quot;0&quot; Required=&quot;false&quot; Scale=&quot;0&quot; /&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Property ID=&quot;RequestTracingEnabled&quot; Type=&quot;string&quot; AutoIncrement=&quot;false&quot; Key=&quot;false&quot; CaseSensitive=&quot;false&quot; MaxLength=&quot;256&quot; MinLength=&quot;0&quot; Required=&quot;false&quot; Scale=&quot;0&quot; /&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Property ID=&quot;HttpLoggingEnabled&quot; Type=&quot;string&quot; AutoIncrement=&quot;false&quot; Key=&quot;false&quot; CaseSensitive=&quot;false&quot; MaxLength=&quot;256&quot; MinLength=&quot;0&quot; Required=&quot;false&quot; Scale=&quot;0&quot; /&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Property ID=&quot;DetailedErrorLoggingEnabled&quot; Type=&quot;string&quot; AutoIncrement=&quot;false&quot; Key=&quot;false&quot; CaseSensitive=&quot;false&quot; MaxLength=&quot;256&quot; MinLength=&quot;0&quot; Required=&quot;false&quot; Scale=&quot;0&quot; /&gt;<br />&nbsp;&nbsp;&nbsp; &lt;/ClassType&gt;<br />&nbsp; &lt;/ClassTypes&gt;<br />&nbsp; &lt;RelationshipTypes&gt;<br />&nbsp;&nbsp;&nbsp; &lt;RelationshipType ID=&quot;Microsoft.SystemCenter.WindowsAzure.Subscription.Hosts.AzureWebApp&quot; Accessibility=&quot;Public&quot; Abstract=&quot;false&quot; Base=&quot;System!System.Hosting&quot;&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Source ID=&quot;Source&quot; MinCardinality=&quot;0&quot; MaxCardinality=&quot;2147483647&quot; Type=&quot;WindowsAzure!Microsoft.SystemCenter.WindowsAzure.Subscription&quot; /&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Target ID=&quot;Target&quot; MinCardinality=&quot;0&quot; MaxCardinality=&quot;2147483647&quot; Type=&quot;Azure.WebApp&quot; /&gt;<br />&nbsp;&nbsp;&nbsp; &lt;/RelationshipType&gt;<br />&nbsp; &lt;/RelationshipTypes&gt;<br />&lt;/EntityTypes&gt;<br />&lt;ModuleTypes&gt;<br />&nbsp; &lt;DataSourceModuleType ID=&quot;Azure.WebApp.PowerShellDiscovery.DS&quot; Accessibility=&quot;Public&quot; Batching=&quot;false&quot; RunAs=&quot;WindowsAzure!Microsoft.SystemCenter.WindowsAzure.RunAsProfile.Proxy&quot;&gt;<br />&nbsp;&nbsp;&nbsp; &lt;Configuration&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xsd:element minOccurs=&quot;1&quot; name=&quot;SourceId&quot; type=&quot;xsd:string&quot; xmlns:xsd=&quot;<a href="https://www.w3.org/2001/XMLSchema&quot;">https://www.w3.org/2001/XMLSchema&quot;</a> /&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xsd:element minOccurs=&quot;1&quot; name=&quot;ManagedEntityId&quot; type=&quot;xsd:string&quot; xmlns:xsd=&quot;<a href="https://www.w3.org/2001/XMLSchema&quot;">https://www.w3.org/2001/XMLSchema&quot;</a> /&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xsd:element minOccurs=&quot;1&quot; name=&quot;IntervalSeconds&quot; type=&quot;xsd:integer&quot; xmlns:xsd=&quot;<a href="https://www.w3.org/2001/XMLSchema&quot;">https://www.w3.org/2001/XMLSchema&quot;</a> /&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xsd:element minOccurs=&quot;1&quot; name=&quot;TimeoutSeconds&quot; type=&quot;xsd:integer&quot; xmlns:xsd=&quot;<a href="https://www.w3.org/2001/XMLSchema&quot;">https://www.w3.org/2001/XMLSchema&quot;</a> /&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xsd:element minOccurs=&quot;1&quot; name=&quot;PathToAzurePSModule&quot; type=&quot;xsd:string&quot; xmlns:xsd=&quot;<a href="https://www.w3.org/2001/XMLSchema&quot;">https://www.w3.org/2001/XMLSchema&quot;</a> /&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xsd:element minOccurs=&quot;1&quot; name=&quot;Debug&quot; type=&quot;xsd:boolean&quot; xmlns:xsd=&quot;<a href="https://www.w3.org/2001/XMLSchema&quot;">https://www.w3.org/2001/XMLSchema&quot;</a> /&gt;<br />&nbsp;&nbsp;&nbsp; &lt;/Configuration&gt;<br />&nbsp;&nbsp;&nbsp; &lt;OverrideableParameters&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;OverrideableParameter ID=&quot;IntervalSeconds&quot; Selector=&quot;$Config/IntervalSeconds$&quot; ParameterType=&quot;int&quot; /&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;OverrideableParameter ID=&quot;TimeoutSeconds&quot; Selector=&quot;$Config/TimeoutSeconds$&quot; ParameterType=&quot;int&quot; /&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;OverrideableParameter ID=&quot;PathToAzurePSModule&quot; Selector=&quot;$Config/PathToAzurePSModule$&quot; ParameterType=&quot;string&quot; /&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;OverrideableParameter ID=&quot;Debug&quot; Selector=&quot;$Config/Debug$&quot; ParameterType=&quot;bool&quot; /&gt;<br />&nbsp;&nbsp;&nbsp; &lt;/OverrideableParameters&gt;<br />&nbsp;&nbsp;&nbsp; &lt;ModuleImplementation Isolation=&quot;Any&quot;&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Composite&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;MemberModules&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;DataSource ID=&quot;DS&quot; TypeID=&quot;System!System.CommandExecuterDiscoveryDataSource&quot;&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;IntervalSeconds&gt;$Config/IntervalSeconds$&lt;/IntervalSeconds&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;ApplicationName&gt;%windir%\system32\WindowsPowerShell\v1.0\powershell.exe&lt;/ApplicationName&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;WorkingDirectory /&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;CommandLine&gt;-NoLogo -NoProfile -Noninteractive &quot;. &#39;$File/DiscoverAzureWebApps.ps1$&#39;&quot;&lt;/CommandLine&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;TimeoutSeconds&gt;$Config/TimeoutSeconds$&lt;/TimeoutSeconds&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;RequireOutput&gt;true&lt;/RequireOutput&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Files&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;File&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Name&gt;DiscoverAzureWebApps.ps1&lt;/Name&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Contents&gt;&lt;![CDATA[<br />param(<br />&nbsp;&nbsp;&nbsp; [string]$SourceId = &quot;$Config/SourceId$&quot;<br />&nbsp;&nbsp;&nbsp; ,[string]$ManagedEntityId=&quot;$Config/ManagedEntityId$&quot;<br />&nbsp;&nbsp;&nbsp; ,[string]$debug=&quot;$Config/Debug$&quot;<br />)</p> <p># normalize debug to bool<br />if ($debug -eq &quot;1&quot; -or $debug.ToLower() -eq &quot;true&quot;) {<br />&nbsp;&nbsp;&nbsp; $debug = $true<br />} else {<br />&nbsp;&nbsp;&nbsp; $debug = $false<br />}</p> <p># configure proxy<br />$webproxy = &quot;$Target/Property[Type=&quot;WindowsAzure!Microsoft.SystemCenter.WindowsAzure.Subscription&quot;]/ProxyServerAddress$&quot;</p> <p>If ($webproxy -ne &quot;&quot;) {<br />&nbsp;&nbsp;&nbsp; if ($webproxy -notmatch &quot;^<a href="https://&quot;)">https://&quot;)</a> { $webproxy = &quot;<a href="https://&quot;">https://&quot;</a> + $webproxy }<br />&nbsp;&nbsp;&nbsp; if ($debug) { $api.LogScriptEvent(&quot;DiscoverAzureWebApps.ps1&quot;, 701, 0, &quot;Using proxy: $webproxy&quot;) }<br />&nbsp;&nbsp;&nbsp; $error.Clear()<br />&nbsp;&nbsp;&nbsp; $proxy = new-object System.Net.WebProxy<br />&nbsp;&nbsp;&nbsp; $proxy.Address = $webproxy<br />&nbsp;&nbsp;&nbsp; #$account = new-object System.Net.NetworkCredential($user,[Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($pwd)), &quot;&quot;)<br />&nbsp;&nbsp;&nbsp; #$proxy.credentials = $account<br />&nbsp;&nbsp;&nbsp; $proxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials<br />&nbsp;&nbsp;&nbsp; [System.Net.WebRequest]::DefaultWebProxy = $proxy<br />&nbsp;&nbsp;&nbsp; if ($error.Count -gt 0) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ($debug) { $api.LogScriptEvent(&quot;DiscoverAzureWebApps.ps1&quot;, 703, 0, &quot;Error configuring proxy: $error&quot;) }<br />&nbsp;&nbsp;&nbsp; }<br />}</p> <p># api and discovery bag staging<br />$api = New-Object -ComObject &#39;MOM.ScriptAPI&#39;<br />$DiscoveryData = $api.CreateDiscoveryData(0, $SourceId, $ManagedEntityId)</p> <p># import module for Azure (hardcoded for now)<br />$error.Clear()<br />import-module &#39;$Config/PathToAzurePSModule$&#39;<br />if ($error.Count -gt 0) {<br />&nbsp;&nbsp;&nbsp; if ($debug) { $api.LogScriptEvent(&quot;DiscoverAzureWebApps.ps1&quot;, 704, 0, &quot;Error importing Azure PowerShell module: $error&quot;) }<br />&nbsp;&nbsp;&nbsp; exit 1<br />}</p> <p># define certificate blob from run as profile<br />$CertBlob=&#39;$RunAs[Name=&quot;WindowsAzure!Microsoft.SystemCenter.WindowsAzure.RunAsProfile.Blob&quot;]/Data$&#39;<br />$CertPassword=&#39;$RunAs[Name=&quot;WindowsAzure!Microsoft.SystemCenter.WindowsAzure.RunAsProfile.Password&quot;]/Password$&#39;<br />$AzureSubId=&#39;$Target/Property[Type=&quot;WindowsAzure!Microsoft.SystemCenter.WindowsAzure.Subscription&quot;]/SubscriptionId$&#39;<br />$AzureSubName=&#39;$Target/Property[Type=&quot;System!System.Entity&quot;]/DisplayName$&#39;</p> <p># decode certificate blob from run as profile<br />$tempBytes=[System.Convert]::FromBase64String($CertBlob)<br />$tempString=[System.Text.Encoding]::Unicode.GetString($tempBytes)<br />$tempBytes=[System.Convert]::FromBase64String($tempString)<br />$AzureCert=New-Object System.Security.Cryptography.X509Certificates.X509Certificate2<br />$AzureCert.Import($tempBytes,$CertPassword,[System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]::MachineKeySet)<br />if ($error.Count -gt 0) {<br />&nbsp;&nbsp;&nbsp; if ($debug) { $api.LogScriptEvent(&quot;DiscoverAzureWebApps.ps1&quot;, 704, 0, &quot;Error reading Azure certificate: $error&quot;) }<br />&nbsp;&nbsp;&nbsp; exit 1<br />}</p> <p># add Azure subscription, name it after the ID to keep it simple and unique<br />$error.Clear()<br />Set-AzureSubscription -SubscriptionId $AzureSubId -Certificate $AzureCert -SubscriptionName $AzureSubId<br />if ($error.Count -gt 0) {<br />&nbsp;&nbsp;&nbsp; if ($debug) { $api.LogScriptEvent(&quot;DiscoverAzureWebApps.ps1&quot;, 704, 0, &quot;Error setting Azure subscription: $error&quot;) }<br />&nbsp;&nbsp;&nbsp; exit 1<br />}</p> <p># select Azure subscripton&nbsp; as current<br />Select-AzureSubscription -Current $AzureSubId</p> <p>$error.Clear()<br /># loop through web apps and create a discovered instance for each<br />foreach ($WebApp in Get-AzureWebsite) {<br />&nbsp;&nbsp;&nbsp; $Instance = $DiscoveryData.CreateClassInstance(&quot;$MPElement[Name=&#39;Azure.WebApp&#39;]$&quot;)<br />&nbsp;&nbsp;&nbsp; $Instance.AddProperty(&quot;$MPElement[Name=&#39;System!System.Entity&#39;]/DisplayName$&quot;, $WebApp.Name)<br />&nbsp;&nbsp;&nbsp; $Instance.AddProperty(&quot;$MPElement[Name=&#39;Azure.WebApp&#39;]/Enabled$&quot;, $WebApp.Enabled)<br />&nbsp;&nbsp;&nbsp; $Instance.AddProperty(&quot;$MPElement[Name=&#39;Azure.WebApp&#39;]/State$&quot;, $WebApp.State.ToString())<br />&nbsp;&nbsp;&nbsp; $Instance.AddProperty(&quot;$MPElement[Name=&#39;Azure.WebApp&#39;]/UsageState$&quot;, $WebApp.UsageState.ToString())<br />&nbsp;&nbsp;&nbsp; $Instance.AddProperty(&quot;$MPElement[Name=&#39;Azure.WebApp&#39;]/HostNames$&quot;, $WebApp.HostNames -join &#39;;&#39;)<br />&nbsp;&nbsp;&nbsp; $Instance.AddProperty(&quot;$MPElement[Name=&#39;Azure.WebApp&#39;]/EnabledHostNames$&quot;, $WebApp.EnabledHostNames -join &#39;;&#39;)<br />&nbsp;&nbsp;&nbsp; $Instance.AddProperty(&quot;$MPElement[Name=&#39;Azure.WebApp&#39;]/AdminEnabled$&quot;, $WebApp.AdminEnabled)<br />&nbsp;&nbsp;&nbsp; $Instance.AddProperty(&quot;$MPElement[Name=&#39;Azure.WebApp&#39;]/Sku$&quot;, $WebApp.Sku.ToString())<br />&nbsp;&nbsp;&nbsp; $Instance.AddProperty(&quot;$MPElement[Name=&#39;Azure.WebApp&#39;]/RepositorySiteName$&quot;, $WebApp.RepositorySiteName)<br />&nbsp;&nbsp;&nbsp; $Instance.AddProperty(&quot;$MPElement[Name=&#39;Azure.WebApp&#39;]/RepositoryUri$&quot;, $(($WebApp.SiteProperties.Properties | ? {$_.Name -eq &quot;RepositoryUri&quot;}).Value))<br />&nbsp;&nbsp;&nbsp; $Instance.AddProperty(&quot;$MPElement[Name=&#39;Azure.WebApp&#39;]/WebSpace$&quot;, $WebApp.WebSpace)<br />&nbsp;&nbsp;&nbsp; $Instance.AddProperty(&quot;$MPElement[Name=&#39;WindowsAzure!Microsoft.SystemCenter.WindowsAzure.Subscription&#39;]/SubscriptionId$&quot;, $AzureSubId)<br />&nbsp;&nbsp;&nbsp; $Instance.AddProperty(&quot;$MPElement[Name=&#39;Azure.WebApp&#39;]/NumberOfWorkers$&quot;, $WebApp.NumberOfWorkers)<br />&nbsp;&nbsp;&nbsp; $Instance.AddProperty(&quot;$MPElement[Name=&#39;Azure.WebApp&#39;]/WebSocketsEnabled$&quot;, $WebApp.WebSocketsEnabled)<br />&nbsp;&nbsp;&nbsp; $Instance.AddProperty(&quot;$MPElement[Name=&#39;Azure.WebApp&#39;]/Use32BitWorkerProcess$&quot;, $WebApp.Use32BitWorkerProcess)<br />&nbsp;&nbsp;&nbsp; $Instance.AddProperty(&quot;$MPElement[Name=&#39;Azure.WebApp&#39;]/DefaultDocuments$&quot;, $WebApp.DefaultDocuments -join &#39;;&#39;)<br />&nbsp;&nbsp;&nbsp; $Instance.AddProperty(&quot;$MPElement[Name=&#39;Azure.WebApp&#39;]/NetFrameworkVersion$&quot;, $WebApp.NetFrameworkVersion)<br />&nbsp;&nbsp;&nbsp; $Instance.AddProperty(&quot;$MPElement[Name=&#39;Azure.WebApp&#39;]/PhpVersion$&quot;, $WebApp.PhpVersion)<br />&nbsp;&nbsp;&nbsp; $Instance.AddProperty(&quot;$MPElement[Name=&#39;Azure.WebApp&#39;]/RequestTracingEnabled$&quot;, $WebApp.RequestTracingEnabled)<br />&nbsp;&nbsp;&nbsp; $Instance.AddProperty(&quot;$MPElement[Name=&#39;Azure.WebApp&#39;]/HttpLoggingEnabled$&quot;, $WebApp.HttpLoggingEnabled)<br />&nbsp;&nbsp;&nbsp; $Instance.AddProperty(&quot;$MPElement[Name=&#39;Azure.WebApp&#39;]/DetailedErrorLoggingEnabled$&quot;, $WebApp.DetailedErrorLoggingEnabled)<br />&nbsp;&nbsp;&nbsp; if ($WebApp.HostNames.Count -gt 1) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $Instance.AddProperty(&quot;$MPElement[Name=&#39;Azure.WebApp&#39;]/URL$&quot;, &quot;<a href="https://$(">https://$(</a>$WebApp.HostNames[0])&quot;)<br />&nbsp;&nbsp;&nbsp; } else {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $Instance.AddProperty(&quot;$MPElement[Name=&#39;Azure.WebApp&#39;]/URL$&quot;, &quot;<a href="https://$(">https://$(</a>$WebApp.HostNames)&quot;)<br />&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; $DiscoveryData.AddInstance($Instance)<br />&nbsp;&nbsp;&nbsp; if ($debug) { $api.LogScriptEvent(&quot;DiscoverAzureWebApps.ps1&quot;, 700, 0, &quot;Added Azure WebApp Instance: $($WebApp.Name)&quot;) }<br />}<br />if ($error.Count -gt 0) {<br />&nbsp;&nbsp;&nbsp; if ($debug) { $api.LogScriptEvent(&quot;DiscoverAzureWebApps.ps1&quot;, 704, 0, &quot;Error reading Azure Web Apps: $error&quot;) }<br />&nbsp;&nbsp;&nbsp; exit 1<br />}<br />$api.Return($DiscoveryData)<br />]]&gt;&lt;/Contents&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/File&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/Files&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/DataSource&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/MemberModules&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Composition&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Node ID=&quot;DS&quot; /&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/Composition&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/Composite&gt;<br />&nbsp;&nbsp;&nbsp; &lt;/ModuleImplementation&gt;<br />&nbsp;&nbsp;&nbsp; &lt;OutputType&gt;System!System.Discovery.Data&lt;/OutputType&gt;<br />&nbsp; &lt;/DataSourceModuleType&gt;<br />&lt;/ModuleTypes&gt;</p> <p><font size="2">Well that’s a start and should help lay some ground work for custom authoring of Azure monitoring. Next round I’ll finish this up with some monitors and talk about ideas around distributing and monitoring for the expected version of Azure PowerShell.</font></p> <h3>&nbsp;</h3> <h3>&nbsp;</h3> <h3>Resources</h3> <p><a title="https://blogs.msdn.com/b/walterm/archive/2013/04/13/first-impressions-on-system-center-management-pack-for-windows-azure-fabric-preview-for-scom-2012-sp1.aspx" href="https://blogs.msdn.com/b/walterm/archive/2013/04/13/first-impressions-on-system-center-management-pack-for-windows-azure-fabric-preview-for-scom-2012-sp1.aspx">https://blogs.msdn.com/b/walterm/archive/2013/04/13/first-impressions-on-system-center-management-pack-for-windows-azure-fabric-preview-for-scom-2012-sp1.aspx</a></p> <p><a title="https://blogs.technet.com/b/heyscriptingguy/archive/2013/06/22/weekend-scripter-getting-started-with-windows-azure-and-powershell.aspx" href="https://blogs.technet.com/b/heyscriptingguy/archive/2013/06/22/weekend-scripter-getting-started-with-windows-azure-and-powershell.aspx">https://blogs.technet.com/b/heyscriptingguy/archive/2013/06/22/weekend-scripter-getting-started-with-windows-azure-and-powershell.aspx</a></p></p></p></p></p></p></p></p>]]></content:encoded>
    </item>
    <item>
      <title>UNIX/Linux Log File Monitor Alert Description Tips</title>
      <link>https://docs.microsoft.com/archive/blogs/cchamp/unixlinux-log-file-monitor-alert-description-tips</link>
      <pubDate>Fri, 09 May 2014 18:54:53 GMT</pubDate>
      <dc:creator><![CDATA[cchamp]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/cchamp/2014/05/09/unixlinux-log-file-monitor-alert-description-tips/</guid>
      <description><![CDATA[Hello! I recently had the opportunity of working with a customer who had a pretty simple ask about...]]></description>
      <content:encoded><![CDATA[<p>Hello! I recently had the opportunity of working with a customer who had a pretty simple ask about log file monitoring. <strong>When using the UNIX/Linux Log File Monitor Management Pack template, how do we include more than just one line that matched, and include all lines that matched since the last interval?</strong></p> <p>This is a really good question, and something you might expect out of the box. There is however some unfavorable behavior with the underlying data source when expecting more than one matching result. In this post I’ll discuss what causes the default behavior of only including one line, and how we can expand that to include additional data that may have matched our log file monitor (er rule).</p> <p>First a few assumptions. This addresses rules that have been created using the UNIX/Linux Log File Monitoring management pack template in System Center 2012 R2 Operations Manager, and the configuration in the rule the template creates has not been modified. For reference the default configuration will look something like:</p> <p>&lt;Configuration&gt;<br />&nbsp; &lt;Host&gt;$Target/Property[Type=&quot;Unix!Microsoft.Unix.Computer&quot;]/PrincipalName$&lt;/Host&gt; <br />&nbsp; &lt;LogFile&gt;/var/log/messages&lt;/LogFile&gt; <br />&nbsp; &lt;UserName&gt;$RunAs[Name=&quot;Unix!Microsoft.Unix.ActionAccount&quot;]/UserName$&lt;/UserName&gt; <br />&nbsp; &lt;Password&gt;$RunAs[Name=&quot;Unix!Microsoft.Unix.ActionAccount&quot;]/Password$&lt;/Password&gt; <br />&nbsp; &lt;RegExpFilter&gt;error 1337&lt;/RegExpFilter&gt; <br />&nbsp; &lt;IndividualAlerts&gt;false&lt;/IndividualAlerts&gt; <br />&lt;/Configuration&gt;</p> <p>And the default alert description will look like:</p> <p>$Data/EventDescription$</p> <p>To find those settings, select the Authoring-&gt;Management Pack Objects-&gt;Rules view, and scope it to UNIX/Linux Computer in the UNIX/Linux Core Library. The LogFile Template rules should show here and be disabled by default (overrides exist to enable to the computer or group specified in the template configuration). Look at the properties of the rule, and under the Configuration tab there are two sections to note. The first contains the Data Source, named something similar to “Log File VarPriv Datasource”. This configures the settings for the UNIX/Linux log file module. The second is the Response, which will contain one named GenerateAlert. This configures the alert settings just as any other console-authored rule or monitor.</p> <p>I mentioned before about some possible unfavorable behavior with the data source, but what does that necessarily mean? In the case of the ask, the alert description contains only one matching line. That’s because the data source feeds the output of the log module to an event mapper. I assume that is done to bring uniformity to the way Windows events and UNIX logs could potentially be stored and reported against, but by using the log file monitoring template, there are no responses for saving the data in the OperationsManager DB or DW as event data present by default. Below is the data source for reference, this was taken from the UNIX/Linux Core Library MP version 7.5.1019.0. I’ve highlighted the cause of the description only containing one line.</p> <p>&lt;DataSourceModuleType ID=&quot;Microsoft.Unix.SCXLog.VarPriv.DataSource&quot; Accessibility=&quot;Public&quot; Batching=&quot;true&quot;&gt;<br />&nbsp; &lt;Configuration&gt;<br />&nbsp;&nbsp;&nbsp; &lt;xsd:element name=&quot;Host&quot; type=&quot;xsd:string&quot; xmlns:xsd=&quot;<a href="https://www.w3.org/2001/XMLSchema&quot;">https://www.w3.org/2001/XMLSchema&quot;</a> /&gt;<br />&nbsp;&nbsp;&nbsp; &lt;xsd:element name=&quot;LogFile&quot; type=&quot;xsd:string&quot; xmlns:xsd=&quot;<a href="https://www.w3.org/2001/XMLSchema&quot;">https://www.w3.org/2001/XMLSchema&quot;</a> /&gt;<br />&nbsp;&nbsp;&nbsp; &lt;xsd:element name=&quot;UserName&quot; type=&quot;xsd:string&quot; xmlns:xsd=&quot;<a href="https://www.w3.org/2001/XMLSchema&quot;">https://www.w3.org/2001/XMLSchema&quot;</a> /&gt;<br />&nbsp;&nbsp;&nbsp; &lt;xsd:element name=&quot;Password&quot; type=&quot;xsd:string&quot; xmlns:xsd=&quot;<a href="https://www.w3.org/2001/XMLSchema&quot;">https://www.w3.org/2001/XMLSchema&quot;</a> /&gt;<br />&nbsp;&nbsp;&nbsp; &lt;xsd:element name=&quot;RegExpFilter&quot; type=&quot;xsd:string&quot; minOccurs=&quot;0&quot; xmlns:xsd=&quot;<a href="https://www.w3.org/2001/XMLSchema&quot;">https://www.w3.org/2001/XMLSchema&quot;</a> /&gt;<br />&nbsp;&nbsp;&nbsp; &lt;xsd:element name=&quot;IndividualAlerts&quot; type=&quot;xsd:boolean&quot; minOccurs=&quot;0&quot; xmlns:xsd=&quot;<a href="https://www.w3.org/2001/XMLSchema&quot;">https://www.w3.org/2001/XMLSchema&quot;</a> /&gt;<br />&nbsp; &lt;/Configuration&gt;<br />&nbsp; &lt;OverrideableParameters&gt;<br />&nbsp;&nbsp;&nbsp; &lt;OverrideableParameter ID=&quot;Host&quot; Selector=&quot;$Config/Host$&quot; ParameterType=&quot;string&quot; /&gt;<br />&nbsp;&nbsp;&nbsp; &lt;OverrideableParameter ID=&quot;LogFile&quot; Selector=&quot;$Config/LogFile$&quot; ParameterType=&quot;string&quot; /&gt;<br />&nbsp;&nbsp;&nbsp; &lt;OverrideableParameter ID=&quot;RegExpFilter&quot; Selector=&quot;$Config/RegExpFilter$&quot; ParameterType=&quot;string&quot; /&gt;<br />&nbsp;&nbsp;&nbsp; &lt;OverrideableParameter ID=&quot;IndividualAlerts&quot; Selector=&quot;$Config/IndividualAlerts$&quot; ParameterType=&quot;bool&quot; /&gt;<br />&nbsp; &lt;/OverrideableParameters&gt;<br />&nbsp; &lt;ModuleImplementation Isolation=&quot;Any&quot;&gt;<br />&nbsp;&nbsp;&nbsp; &lt;Composite&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;MemberModules&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;DataSource ID=&quot;DS&quot; TypeID=&quot;Microsoft.Unix.SCXLog.Native.DataSource&quot;&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Protocol&gt;https&lt;/Protocol&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Host&gt;$Config/Host$&lt;/Host&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;UserName&gt;$Config/UserName$&lt;/UserName&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Password&gt;$Config/Password$&lt;/Password&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;LogFile&gt;$Config/LogFile$&lt;/LogFile&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;RegExpFilter&gt;$Config/RegExpFilter$&lt;/RegExpFilter&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;IndividualAlerts&gt;$Config/IndividualAlerts$&lt;/IndividualAlerts&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;QId&gt;$Target/ManagementGroup/Name$&lt;/QId&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;IntervalSeconds&gt;300&lt;/IntervalSeconds&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;SkipCACheck&gt;false&lt;/SkipCACheck&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;SkipCNCheck&gt;false&lt;/SkipCNCheck&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/DataSource&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;ConditionDetection ID=&quot;Mapper&quot; TypeID=&quot;System!System.Event.GenericDataMapper&quot;&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;EventOriginId&gt;$Target/Id$&lt;/EventOriginId&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;PublisherId&gt;$MPElement$&lt;/PublisherId&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;PublisherName&gt;WSManEventProvider&lt;/PublisherName&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Channel&gt;WSManEventProvider&lt;/Channel&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;LoggingComputer /&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;EventNumber&gt;0&lt;/EventNumber&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;EventCategory&gt;3&lt;/EventCategory&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;EventLevel&gt;0&lt;/EventLevel&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;UserName /&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font style="background-color:#ffff00;">&lt;Description&gt;Detected Entry:&nbsp; $Data///row$&lt;/Description&gt;</font><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Params /&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/ConditionDetection&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/MemberModules&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Composition&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Node ID=&quot;Mapper&quot;&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Node ID=&quot;DS&quot; /&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/Node&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/Composition&gt;<br />&nbsp;&nbsp;&nbsp; &lt;/Composite&gt;<br />&nbsp; &lt;/ModuleImplementation&gt;<br />&nbsp; &lt;OutputType&gt;System!System.BaseData&lt;/OutputType&gt;<br />&lt;/DataSourceModuleType&gt;<br /></p> <p>To change this behavior though, we want to focus on the <strong>GenerateAlert</strong> response. Click Edit to view the settings, and locate the Alert description field. There are two ways we might accomplish our goal. The first is we can include ALL lines that have matched in the past interval, but all the lines appear run together on a single line. Or we can include up to the first 10 matching lines by addressing those first 10 rows of the data returned individually.</p> <p>To get all the data collapsed on a single line, use the following as the description:</p> <p>Detected Entries: $Data///SCXLogProviderDataSourceData$</p> <p>&nbsp;</p> <p>To get only the first 10 matches, but each on their own line, use this as the description:</p> <p>Up to the first 10 matching entries:<br />$Data///row[1]$<br />$Data///row[2]$<br />$Data///row[3]$<br />$Data///row[4]$<br />$Data///row[5]$<br />$Data///row[6]$<br />$Data///row[7]$<br />$Data///row[8]$<br />$Data///row[9]$<br />$Data///row[10]$</p> <p>&nbsp;</p> <p>For reference, here is what the Alert Context for one of these rules looks like. This is the data that will be processed for the variable substitution in the alert description.</p> <p>&lt; DataItem type =&quot; SCXLogProviderDataSourceData &quot; time =&quot; 2014-05-09T20:52:59.9407442-04:00 &quot; sourceHealthServiceId =&quot; 146F6C57-9775-06DE-9590-B2B9A2D11920 &quot; &gt; <br />&lt; SCXLogProviderDataSourceData &gt; <br />&nbsp; &lt; row &gt; May 9 20:50:30 centos6 root: error 1337: ltnz overload, 2-1337-2 proceed to level 1. &lt;/ row &gt; <br />&nbsp; &lt; row &gt; May 9 20:50:30 centos6 root: error 1337: ltnz overload, 2-1337-2 proceed to level 2. &lt;/ row &gt; <br />&nbsp; &lt; row &gt; May 9 20:50:30 centos6 root: error 1337: ltnz overload, 2-1337-2 proceed to level 3. &lt;/ row &gt; <br />&nbsp; &lt; row &gt; May 9 20:50:30 centos6 root: error 1337: ltnz overload, 2-1337-2 proceed to level 4. &lt;/ row &gt; <br />&nbsp; &lt; row &gt; May 9 20:50:30 centos6 root: error 1337: ltnz overload, 2-1337-2 proceed to level 5. &lt;/ row &gt; <br />&nbsp; &lt; row &gt; May 9 20:50:30 centos6 root: error 1337: ltnz overload, 2-1337-2 proceed to level 6. &lt;/ row &gt; <br />&nbsp; &lt; row &gt; May 9 20:50:30 centos6 root: error 1337: ltnz overload, 2-1337-2 proceed to level 7. &lt;/ row &gt; <br />&nbsp; &lt; row &gt; May 9 20:50:30 centos6 root: error 1337: ltnz overload, 2-1337-2 proceed to level 8. &lt;/ row &gt; <br />&nbsp; &lt; row &gt; May 9 20:50:30 centos6 root: error 1337: ltnz overload, 2-1337-2 proceed to level 9. &lt;/ row &gt; <br />&nbsp; &lt; row &gt; May 9 20:50:30 centos6 root: error 1337: ltnz overload, 2-1337-2 proceed to level 10. &lt;/ row &gt; <br />&nbsp; &lt;/ SCXLogProviderDataSourceData &gt; <br />&lt;/ DataItem &gt;</p> <p>Looking at the above, and if you have any experience with XPath queries, you can see the alert description settings proposed above are nothing too complicated. The first method above addresses the SCXLogProviderDataSourceData XML node, and returns everything below on one line. The second method calls out to the row node and calls out to the [1], [2], [3], … instance of the row entry. If only 3 rows are returned, the other 7 will remain blank and thankfully not result in an error.</p> <p>&nbsp;</p> <p>Follow up question. Now with the matching lines in the alert, <strong>how do we generate a new alert for every set of matches found, but not for each line found?</strong> By default, the Data Source is configured with IndividualAlerts set to false which causes any future log matches by the rule to increment the existing alert’s repeat count. Whereas when IndividualAlerts is set to true, each line creates its own alert. We can address this using the alert suppression settings (view the rule properties/configuration, and modify the GenerateAlert response where there will be an Alert Settings button at the bottom). And we only need one entry:</p> <p>$Data///SCXLogProviderDataSourceData$</p> <p>By adding that line above, it forces an additional evaluation to the alert suppression, and assuming there are date/time stamps in the log file, even if the same set of errors match, we’ll receive a new alert. Be sure to close any open alerts that were raised prior to modifying the suppression settings. Otherwise the alerts will still enforce suppression as it was configured at the time the alert was raised.</p> <p>&nbsp;</p> <p>Using this information you should be able to custom tailor the alert description better than what the template provides out of the box, and what I really appreciate about these methods is that it can all be done from the Operations Console.</p> <p>&nbsp;</p> <p>Now for the instant gratification types, screenshots!</p> <p>BEFORE:<br /><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/73/77/metablogapi/image_0D0660A7.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-73-77-metablogapi/image_5F00_0D0660A7.png"><img title="image" style="border-left-width:0px;border-right-width:0px;background-image:none;border-bottom-width:0px;padding-top:0px;padding-left:0px;display:inline;padding-right:0px;border-top-width:0px;" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/73/77/metablogapi/image_thumb_63FE525B.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-73-77-metablogapi/image_5F00_thumb_5F00_63FE525B.png" width="568" height="220" /></a></p> <p>AFTER ON A SINGLE LINE:<br /><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/73/77/metablogapi/image_7ECA7867.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-73-77-metablogapi/image_5F00_7ECA7867.png"><img title="image" style="border-left-width:0px;border-right-width:0px;background-image:none;border-bottom-width:0px;padding-top:0px;padding-left:0px;display:inline;padding-right:0px;border-top-width:0px;" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/73/77/metablogapi/image_thumb_20B5DAEC.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-73-77-metablogapi/image_5F00_thumb_5F00_20B5DAEC.png" width="571" height="323" /></a></p> <p>AFTER WITH ROWS:<br /><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/73/77/metablogapi/image_1E0FAFEC.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-73-77-metablogapi/image_5F00_1E0FAFEC.png"><img title="image" style="border-left-width:0px;border-right-width:0px;background-image:none;border-bottom-width:0px;padding-top:0px;padding-left:0px;display:inline;padding-right:0px;border-top-width:0px;" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/73/77/metablogapi/image_thumb_6DE86528.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-73-77-metablogapi/image_5F00_thumb_5F00_6DE86528.png" width="573" height="428" /></a></p> <p><font size="2">Known Issues</font></p> <ul> <li>Once you modify the alert settings, you should not edit the rule using the Management Pack Template. In fact, once you have the log file rules dialed-in, I would open the MP XML and remove any line that begins with &lt;Folder ID=&quot;TemplateoutputMicrosoftUnixLogFileTemplate or &lt;FolderItem ElementID=&quot;LogFileTemplate, and be sure to tidy up any remaining &lt;Folders&gt; and &lt;FolderItems&gt; tags if you don’t have any legitimate folders for Monitoring views.<br /><strong>IF YOU DO EDIT THE MP TEMPLATE, YOU WILL OVERWRITE CHANGES MADE TO THE RULE AND ALERT DESCRIPTION WITH THE DEFAULTS.</strong>  </li><li>There is a limit to ten lines using the individual row method. The limit is imposed by ten alert parameters max. You could increase this by passing as many rows as you could squeeze into the event data mapper data source by copy/pasting from the UNIX/Linux Core Library (and grab Microsoft.Unix.SCXLog.Native.DataSource too since it will be needed and is marked internal), or even insert a custom data source for post-processing. This is more ideal if you consistently author using more robust authoring tools and/or the raw XML.  </li><li>Technically we are duplicating what can amount to a significant amount of data depending on how often the alert triggers. The log entries will be stored in the alert context field, as well as the alert parameters field. Generally speaking this shouldn’t be too much of a concern, but it’s worth mentioning in case anyone is planning on alert archives with 10’s of 1000’s of these.</li></ul> <p><font size="2">Resources</font></p> <p><a href="https://blogs.technet.com/b/kevinholman/archive/2007/12/12/adding-custom-information-to-alert-descriptions-and-notifications.aspx">Adding custom information to alert description (s) and notifications</a> – An oldie, but goodie on Kevin Holman’s blog. My go to link for alert variable reference.</p> <p><a href="https://msdn.microsoft.com/en-us/library/jj129900.aspx">AlertParameters (UnitMonitor)</a> – This is good reference on the fact there are only 10 alert parameters. The AlertSettings block is different for rules, so beware.</p> <p><a href="https://social.technet.microsoft.com/wiki/contents/articles/18085.scom-2012-authoring-unixlinux-log-file-monitoring-rules.aspx">SCOM 2012: Authoring UNIX/Linux Log File Monitoring Rules</a> – Good article on custom authoring Log File Monitoring rules, plus details on using the correlated condition detect module with UNIX/Linux logs (need x occurrences in y time).</p>]]></content:encoded>
    </item>
    <item>
      <title>How to find Subscriptions with deleted Rules and Monitors</title>
      <link>https://docs.microsoft.com/archive/blogs/cchamp/how-to-find-subscriptions-with-deleted-rules-and-monitors</link>
      <pubDate>Mon, 10 Mar 2014 19:35:12 GMT</pubDate>
      <dc:creator><![CDATA[cchamp]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/cchamp/2014/03/10/how-to-find-subscriptions-with-deleted-rules-and-monitors/</guid>
      <description><![CDATA[… Or an introduction to subscription criteria.  What I want to share today is a PowerShell snippet...]]></description>
      <content:encoded><![CDATA[<p>… Or an introduction to subscription criteria.  <p>What I want to share today is a PowerShell snippet I&#39;ve been sitting on that checks out the current subscriptions for rules or monitors that no longer exist. With some of the newer management packs replacing their old versions, this can really help save some time in tracking down one-off subscriptions that tie to those old rules and monitors. Also, it&#39;s always good to check this before performing any major migration or upgrade say from 2007 R2 to 2012. And there is always the case you might find yourself trying to edit a complex subscription and it’s resulting in a System.NullReferenceException error in the console. <p>Without further ado, the snippets…  <p>2007 R2:<pre class="csharpcode"><span class="kwrd">foreach</span> ($notificationsub <span class="kwrd">in</span> Get-NotificationSubscription) {
    $notificationsubname=$notificationsub.DisplayName
    $writesub = $<span class="kwrd">true</span>
    $criteria = [xml]$notificationsub.Configuration.Criteria.ToString()
    $xmlnsmgr = New-Object System.Xml.XmlNamespaceManager $criteria.CreateNavigator().NameTable
    <span class="kwrd">foreach</span> ($simpexpr <span class="kwrd">in</span> $criteria.SelectNodes(<span class="str">&quot;//SimpleExpression&quot;</span>, $xmlnsmgr)) {
        $property = <span class="str">&quot;&quot;</span>
        $guid=0
        $element=$<span class="kwrd">null</span>
        $property = $simpexpr.GetElementsByTagName(<span class="str">&quot;Property&quot;</span>).Item(0).<span class="str">&quot;#text&quot;</span>.ToString()
        <span class="kwrd">if</span> ($property -eq <span class="str">&quot;RuleId&quot;</span> -or $property -eq <span class="str">&quot;ProblemId&quot;</span>) {
            $<span class="kwrd">value</span> = $simpexpr.GetElementsByTagName(<span class="str">&quot;Value&quot;</span>).Item(0).<span class="str">&quot;#text&quot;</span>.ToString()
            <span class="kwrd">try</span> {
                $guid=[guid]$<span class="kwrd">value</span>
            } <span class="kwrd">catch</span> {}            
        }
        <span class="kwrd">if</span> ($guid -ne 0) {
            <span class="kwrd">if</span> ($property -eq <span class="str">&quot;RuleId&quot;</span>) {
                $element=Get-Rule -Criteria <span class="str">&quot;Id = &#39;$guid&#39;&quot;</span>
            } <span class="kwrd">else</span> {
                $element=Get-Monitor -Criteria <span class="str">&quot;Id = &#39;$guid&#39;&quot;</span>
            }
            <span class="kwrd">if</span> ($element -eq $<span class="kwrd">null</span>) {
                <span class="kwrd">if</span> ($writesub) {
                    Write-Output <span class="str">&quot;&quot;</span>
                    Write-Output <span class="str">&quot;Subscription: $notificationsub&quot;</span>
                    Write-Output <span class="str">&quot;Name: $notificationsubname&quot;</span>
                    Write-Output <span class="str">&quot;------------------------------------------------------------------------------&quot;</span>
                    $writesub=$<span class="kwrd">false</span>
                }
                <span class="kwrd">if</span> ($property -eq <span class="str">&quot;RuleId&quot;</span>) {
                    Write-Output <span class="str">&quot;Rule: $guid&quot;</span>
                } <span class="kwrd">else</span> {
                    Write-Output <span class="str">&quot;Monitor: $guid&quot;</span>
                }
            }
        }
    }
    <span class="kwrd">if</span> (!$writesub) {
        Write-Output <span class="str">&quot;&quot;</span>
    }
}

</pre>


<p>2012:<pre class="csharpcode"><span class="kwrd">foreach</span> ($notificationsub <span class="kwrd">in</span> Get-SCOMNotificationSubscription) {
  $notificationsubname=$notificationsub.DisplayName
  $writesub = $<span class="kwrd">true</span>
  <span class="kwrd">if</span> ($notificationsub.Configuration.Criteria -ne $<span class="kwrd">null</span>) {
    $criteria = [xml]$notificationsub.Configuration.Criteria.ToString()
    $xmlnsmgr = New-Object System.Xml.XmlNamespaceManager $criteria.CreateNavigator().NameTable
    <span class="kwrd">foreach</span> ($simpexpr <span class="kwrd">in</span> $criteria.SelectNodes(<span class="str">&quot;//SimpleExpression&quot;</span>, $xmlnsmgr)) {
        $property = <span class="str">&quot;&quot;</span>
        $guid=0
        $element=$<span class="kwrd">null</span>
        $property = $simpexpr.GetElementsByTagName(<span class="str">&quot;Property&quot;</span>).Item(0).<span class="str">&quot;#text&quot;</span>.ToString()
        <span class="kwrd">if</span> ($property -eq <span class="str">&quot;RuleId&quot;</span> -or $property -eq <span class="str">&quot;ProblemId&quot;</span>) {
            $<span class="kwrd">value</span> = $simpexpr.GetElementsByTagName(<span class="str">&quot;Value&quot;</span>).Item(0).<span class="str">&quot;#text&quot;</span>.ToString()
            <span class="kwrd">try</span> {
                $guid=[guid]$<span class="kwrd">value</span>
            } <span class="kwrd">catch</span> {}            
        }
        <span class="kwrd">if</span> ($guid -ne 0) {
            <span class="kwrd">if</span> ($property -eq <span class="str">&quot;RuleId&quot;</span>) {
                $element=Get-SCOMRule -Id $guid
            } <span class="kwrd">else</span> {
                $element=Get-SCOMMonitor -Id $guid
            }
            <span class="kwrd">if</span> ($element -eq $<span class="kwrd">null</span>) {
                <span class="kwrd">if</span> ($writesub) {
                    Write-Output <span class="str">&quot;&quot;</span>
                    Write-Output <span class="str">&quot;Subscription: $notificationsub&quot;</span>
                    Write-Output <span class="str">&quot;Name: $notificationsubname&quot;</span>
                    Write-Output <span class="str">&quot;------------------------------------------------------------------------------&quot;</span>
                    $writesub=$<span class="kwrd">false</span>
                }
                <span class="kwrd">if</span> ($property -eq <span class="str">&quot;RuleId&quot;</span>) {
                    Write-Output <span class="str">&quot;Rule: $guid&quot;</span>
                } <span class="kwrd">else</span> {
                    Write-Output <span class="str">&quot;Monitor: $guid&quot;</span>
                }
            }
        }
    }
    <span class="kwrd">if</span> (!$writesub) {
        Write-Output <span class="str">&quot;&quot;</span>
    }
   }
}
</pre>


<p>Well that’s great and all, but how do we use it? 
<p>In either case of 2007 or 2012, either save the above script to a PS1 file or copy/paste it directly into the Operations Manager Shell. 
<p>Once run, one of two things may happen: 
<p>1) No output. Great! No problem. 
<p>2) Output… 
<p>Subscription: Subscription26c89132_b882_4d51_9924_74724e3bed9e<br />Name: Broken Sub<br />------------------------------------------------------------------------------<br />Rule: 36f41859-7246-60c9-1a24-834c9597fc42 
<p>Okay, so it found a subscription and returned a Rule’s GUID. It can’t return the name of the rule since it no longer exists. To fix this, either modify the Notification Internal Library MP XML or just remove the entire subscription and rebuild it from scratch. 
<p>Note, as tested in the 2012 SP1 console, when criteria contains a missing rule/monitor and it was <strong><em>the only one</em></strong> specified in the criteria, the UI will present it as though no criteria for the specific rule/monitor has been specified. If multiple rules/monitors are specified and one is missing, the console will not allow you to modify the criteria. Although different factors could result in different behavior, and therefore experiences may vary. 
<p>In order to modify the MP XML with this rule, first export the Notifications Internal Library MP aka Microsoft.SystemCenter.Notifications.Internal.xml. 
<p>Then search for the GUID returned by the PowerShell, in the example this was 36f41859-7246-60c9-1a24-834c9597fc42. It should be found in a &lt;Criteria&gt; block:<pre class="csharpcode">              &lt;Criteria&gt;
                &lt;Expression&gt;
                  &lt;SimpleExpression xmlns:xsd=<span class="str">&quot;https://www.w3.org/2001/XMLSchema&quot;</span> xmlns:xsi=<span class="str">&quot;https://www.w3.org/2001/XMLSchema-instance&quot;</span>&gt;
                    &lt;ValueExpression&gt;
                      &lt;Property&gt;RuleId&lt;/Property&gt;
                    &lt;/ValueExpression&gt;
                    &lt;Operator&gt;Equal&lt;/Operator&gt;
                    &lt;ValueExpression&gt;
                      &lt;Value&gt;36f41859-7246-60c9-1a24-834c9597fc42&lt;/Value&gt;
                    &lt;/ValueExpression&gt;
                  &lt;/SimpleExpression&gt;
                &lt;/Expression&gt;
              &lt;/Criteria&gt;
</pre>


<p>In this case that rule is the only criteria, so to go a step further, the whole rule can be deleted (everything between and including the &lt;Rule ID=&quot;Subscription26c89132_b882_4d51_9924_74724e3bed9e&quot;… and &lt;/Rule&gt; tags). Then also remove the associated DisplayString block near the end of the MP. 
<p>In the case where it is not the only criteria, it can get a bit complex:<pre class="csharpcode">              &lt;Criteria&gt;
                &lt;Expression&gt;
                  &lt;And xmlns:xsd=<span class="str">&quot;https://www.w3.org/2001/XMLSchema&quot;</span> xmlns:xsi=<span class="str">&quot;https://www.w3.org/2001/XMLSchema-instance&quot;</span>&gt;
                    &lt;Expression&gt;
                      &lt;Or&gt;
                        &lt;Expression&gt;
                          &lt;SimpleExpression&gt;
                            &lt;ValueExpression&gt;
                              &lt;Property&gt;ProblemId&lt;/Property&gt;
                            &lt;/ValueExpression&gt;
                            &lt;Operator&gt;Equal&lt;/Operator&gt;
                            &lt;ValueExpression&gt;
                              &lt;Value&gt;d064c5b4-1ca9-a551-04b3-8a6d6ca9919f&lt;/Value&gt;
                            &lt;/ValueExpression&gt;
                          &lt;/SimpleExpression&gt;
                        &lt;/Expression&gt;
                        &lt;Expression&gt;
                          &lt;SimpleExpression&gt;
                            &lt;ValueExpression&gt;
                              &lt;Property&gt;RuleId&lt;/Property&gt;
                            &lt;/ValueExpression&gt;
                            &lt;Operator&gt;Equal&lt;/Operator&gt;
                            &lt;ValueExpression&gt;
                              &lt;Value&gt;36f41859-7246-60c9-1a24-834c9597fc42&lt;/Value&gt;
                            &lt;/ValueExpression&gt;
                          &lt;/SimpleExpression&gt;
                        &lt;/Expression&gt;
                      &lt;/Or&gt;
                    &lt;/Expression&gt;
                    &lt;Expression&gt;
                      &lt;SimpleExpression&gt;
                        &lt;ValueExpression&gt;
                          &lt;Property&gt;Severity&lt;/Property&gt;
                        &lt;/ValueExpression&gt;
                        &lt;Operator&gt;Equal&lt;/Operator&gt;
                        &lt;ValueExpression&gt;
                          &lt;Value&gt;2&lt;/Value&gt;
                        &lt;/ValueExpression&gt;
                      &lt;/SimpleExpression&gt;
                    &lt;/Expression&gt;
                  &lt;/And&gt;
                &lt;/Expression&gt;
              &lt;/Criteria&gt;
</pre>


<p>In short we need to remove the &lt;Expression&gt; block that contains the missing rule, but in the above case we have additional criteria that takes some careful consideration. And that is that the Rule/Monitor criteria is wrapped in an &lt;Or&gt; block, with additional criteria contained in an &lt;And&gt; block. A quick note about &lt;Or&gt; and &lt;And&gt; blocks, they require at least two &lt;Expression&gt; blocks. With that in mind, if &lt;Expression&gt; block containing the missing rule is removed, the MP XML will become invalid. In that case we need to remove the &lt;Expression&gt; and &lt;Or&gt; tags, along with their matching closing tags, but leaving the part of the desired criteria (the ProblemId expression). Since that barely made sense typing it, this is what the end result would look like:<pre class="csharpcode">              &lt;Criteria&gt;
                &lt;Expression&gt;
                  &lt;And xmlns:xsd=<span class="str">&quot;https://www.w3.org/2001/XMLSchema&quot;</span> xmlns:xsi=<span class="str">&quot;https://www.w3.org/2001/XMLSchema-instance&quot;</span>&gt;
                        &lt;Expression&gt;
                          &lt;SimpleExpression&gt;
                            &lt;ValueExpression&gt;
                              &lt;Property&gt;ProblemId&lt;/Property&gt;
                            &lt;/ValueExpression&gt;
                            &lt;Operator&gt;Equal&lt;/Operator&gt;
                            &lt;ValueExpression&gt;
                              &lt;Value&gt;d064c5b4-1ca9-a551-04b3-8a6d6ca9919f&lt;/Value&gt;
                            &lt;/ValueExpression&gt;
                          &lt;/SimpleExpression&gt;
                        &lt;/Expression&gt;
                    &lt;Expression&gt;
                      &lt;SimpleExpression&gt;
                        &lt;ValueExpression&gt;
                          &lt;Property&gt;Severity&lt;/Property&gt;
                        &lt;/ValueExpression&gt;
                        &lt;Operator&gt;Equal&lt;/Operator&gt;
                        &lt;ValueExpression&gt;
                          &lt;Value&gt;2&lt;/Value&gt;
                        &lt;/ValueExpression&gt;
                      &lt;/SimpleExpression&gt;
                    &lt;/Expression&gt;
                  &lt;/And&gt;
                &lt;/Expression&gt;
              &lt;/Criteria&gt;
</pre>


<p>Be cautious when there is only one rule/monitor specified, but other criteria is present such as severity. If the rule/monitor criteria is removed, but the severity match remains, then it would change the subscription to match all alerts raised with that particular severity. 
<p>Once the XML has been modified to fit the new desired criteria, try to import the MP (preferably in a Lab/Dev/QA environment). If an error is returned hopefully it is descriptive enough to fix the issue. If not retrace the steps to make sure all XML tags have a valid start/end, and that there are no orphaned DisplayStrings if a Rule was removed. Once it imports, the issue should resolved. 
<p>What if: 
<p>- I’m not too good modifying XML: I recommend deleting and rebuilding the subscription. 
<p>- I have hundreds of these! 
<p>Theoretically this could be automated, but it would take a pretty fair understanding of XML and the criteria schema to check for the aforementioned scenarios, as well as any others I didn’t consider. The nice thing is if the criteria is broken, it won’t import the management pack. If there’s interest in an automated 2012 version, feel free to leave a comment and let me know. 
<p>Here are some resources that may be of some use: 
<p>ExpressionType Reference<br /><a href="https://msdn.microsoft.com/en-us/library/jj130463.aspx">https://msdn.microsoft.com/en-us/library/jj130463.aspx</a> 
<p>Configuring Operations Manager 2007 R2 Product Connector Subscription Advanced Criteria – In case you came across this article to gain a deeper understanding notification subscription criteria or the ExpressionType syntax<br /><a href="https://support.microsoft.com/?kbid=2026093">https://support.microsoft.com/?kbid=2026093</a> 
<p>“remove section of an XML file” – Where I might start if I were to automate this process. Keep in mind portions of criteria in And/Or statements that are intended to remain will need saved to a new node before the entire And/Or nodes are deleted.<br /><a href="https://social.technet.microsoft.com/Forums/windowsserver/en-US/702f3e4a-df64-4a97-af8b-1e247b6633e2/remove-section-of-an-xml-file?forum=winserverpowershell">https://social.technet.microsoft.com/Forums/windowsserver/en-US/702f3e4a-df64-4a97-af8b-1e247b6633e2/remove-section-of-an-xml-file?forum=winserverpowershell</a> 
<p>Last, but not least: This is information is provided as-is and provides no warranty. Always maintain a backup of your management packs, and never work on notification subscriptions in a production environment. 
</p></p></p></p></p></p></p></p></p></p></p></p></p></p></p></p></p></p></p></p></p></p></p></p></p></p></p></p></p>]]></content:encoded>
    </item>
    <item>
      <title>Example MP to Trigger Non-stop Notifications</title>
      <link>https://docs.microsoft.com/archive/blogs/cchamp/example-mp-to-trigger-non-stop-notifications</link>
      <pubDate>Wed, 04 Nov 2009 12:48:00 GMT</pubDate>
      <dc:creator><![CDATA[cchamp]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/cchamp/2009/11/04/example-mp-to-trigger-non-stop-notifications/</guid>
      <description><![CDATA[Occasionally I speak to someone who would like to have OpsMgr continually send notifications until...]]></description>
      <content:encoded><![CDATA[<P>Occasionally I speak to someone who would like to have OpsMgr continually send notifications until an alert is resolved. One way this can be done is by setting up multiple notification subscriptions and staggering the alert aging. The problem with this method is it is finite, and can be quite tedious to setup.</P>
<P>Alternately, we can have a process run one a timed interval to modify certain open alerts in a manner that would trigger another notification to be sent. One way to trigger that is to update a custom field.</P>
<P>So as an example of how to accomplish this, here is a small management pack that includes a Timed Command Rule that executes a script (VBS with Powershell embedded) on the RMS. The script is setup to run every 5 minutes, and will update Custom Field 10 in order to trigger a new notification when it is run. If anything exists in Custom Field 10 already it will be overwritten. <SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt">The MP should work with OpsMgr 2007 SP1 and newer.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></P>
<P>Please note that&nbsp;the management pack in its current form can be <SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA">detrimental </SPAN>to performance. It will affect ALL alerts that are not closed (resolution state 255). If you have quite a few open alerts, it could potentially consume quite a bit of CPU to update the alerts, and also consume additional resources when the notification workflow runs to send out the notifications. Not to mention any adverse effects that could be caused by the increased size of the alert history which will grow with each run.</P>
<P><STRONG>This is of course provided AS-IS and as an EXAMPLE only.<BR></STRONG></P>
<p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/telligent.evolution.components.attachments/01/7377/00/00/03/29/15/31/Custom.Field.Updater.xml" original-url="https://blogs.technet.com/cfs-filesystemfile.ashx/__key/telligent-evolution-components-attachments/01-7377-00-00-03-29-15-31/Custom.Field.Updater.xml">Custom.Field.Updater.xml</a></p>]]></content:encoded>
    </item>
  </channel>
</rss>