<?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>Philip Van de Vyver on SCOM and Azure Log Analytics</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/philipvandevyver/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/philipvandevyver/feed.xml</link>
    <description>Information out of the field on Operations Manager and Azure Log Analytics</description>
    <lastBuildDate>Tue, 16 Apr 2019 06:22:10 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>SCOM - OMS Gateway Monitoring Addendum Management Pack</title>
      <link>https://docs.microsoft.com/archive/blogs/philipvandevyver/scom-oms-gateway-monitoring</link>
      <pubDate>Tue, 24 Apr 2018 19:19:13 GMT</pubDate>
      <dc:creator><![CDATA[Philip Van de Vyver]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/philipvandevyver/?p=565</guid>
      <description><![CDATA[Sometimes, it's not clear how many clients that are reporting and if there are any errors with the...]]></description>
      <content:encoded><![CDATA[Sometimes, it's not clear how many clients that are reporting and if there are any errors with the OMS gateway.

If you use SCOM, you can use it to visualize performance, event and health state of the OMS gateway.

The OMS documentation is clear on what kind of performance counters and event data that we can use: <a href="https://docs.microsoft.com/en-us/azure/log-analytics/log-analytics-oms-gateway">https://docs.microsoft.com/en-us/azure/log-analytics/log-analytics-oms-gateway</a>

I created an addon Management Pack called "Microsoft System Center Advisor Monitoring Addendum OMS Gateway".

The Management Pack contains the following:
<h2>State view</h2>
<img width="879" height="543" class="alignnone size-large wp-image-575" alt="" src="https://msdnshared.blob.core.windows.net/media/2018/04/OMS_Gateway_State-1024x633.png" />

The Management Pack discovers an OMS Gateway Server class with a bunch of useful properties.
There is one Monitor active on the OMS Gateway Server class that monitors the Service of the OMS Gateway.
<h2>Performance View</h2>
<img width="879" height="542" class="alignnone size-large wp-image-585" alt="" src="https://msdnshared.blob.core.windows.net/media/2018/04/OMS_Gateway_Performance-1024x631.png" />

The Management Pack collects 4 performance counters with the following performance collection rules:

<img width="879" height="74" class="alignnone size-large wp-image-605" alt="" src="https://msdnshared.blob.core.windows.net/media/2018/04/OMS_Gateway_Performance_Collection-1024x86.png" />
<table>
<thead>
<tr>
<th><strong>Name</strong></th>
<th><strong>Description</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td>OMS Gateway/Active Client Connection</td>
<td>Number of active client network (TCP) connections</td>
</tr>
<tr>
<td>OMS Gateway/Error Count</td>
<td>Number of errors</td>
</tr>
<tr>
<td>OMS Gateway/Connected Client</td>
<td>Number of connected clients</td>
</tr>
<tr>
<td>OMS Gateway/Rejection Count</td>
<td>Number of rejections due to any TLS validation error</td>
</tr>
</tbody>
</table>
<h2>Event view</h2>
<img width="879" height="543" class="alignnone size-large wp-image-595" alt="" src="https://msdnshared.blob.core.windows.net/media/2018/04/OMS_Gateway_Events-1024x633.png" />

<span style="float: none;background-color: transparent;color: #333333;cursor: text;font-family: Georgia,'Times New Roman','Bitstream Charter',Times,serif;font-size: 16px;font-style: normal;font-variant: normal;font-weight: 400;letter-spacing: normal;line-height: 24px;text-align: left;text-decoration: none;text-indent: 0px">The Management Pack collects 6 events with the following event collection rules (no alerting):</span>

<img width="879" height="103" class="alignnone size-large wp-image-615" alt="" src="https://msdnshared.blob.core.windows.net/media/2018/04/OMS_Gateway_Events_Collection-1024x120.png" />
<table>
<thead>
<tr>
<th><strong>Name</strong></th>
<th><strong>Description</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td>OMS Gateway - Event Collection Event 105</td>
<td>Destination server is not in allowed list or the destination port is not secure port (443).
Ensure that the MMA agent on your Gateway server and the agents that are communicating with the Gateway are connected to the same Log Analytics workspace.
or
ERROR TcpConnection – Invalid Client certificate: CN=Gateway
Ensure that:
- You are using a Gateway with version number 1.0.395.0 or greater.
- The MMA agent on your Gateway server and the agents that are communicating with the gateway are connected to the same Log Analytics workspace.</td>
</tr>
<tr>
<td>OMS Gateway - Event Collection Event 106</td>
<td>The OMS Gateway only supports TLS 1.0, TLS 1.1 and 1.2. It does not support SSL. For any unsupported TLS/SSL protocol version, OMS Gateway generates event ID 106.</td>
</tr>
<tr>
<td>OMS Gateway - Event Collection Event 400</td>
<td>Any application error that does not have a specific ID.</td>
</tr>
</tbody>
<tbody>
<tr>
<td>OMS Gateway - Event Collection Event 401</td>
<td>Wrong configuration. For example: listenPort = "text" instead of an integer.</td>
</tr>
<tr>
<td>OMS Gateway - Event Collection Event 402</td>
<td>Exception in parsing TLS handshake messages</td>
</tr>
<tr>
<td>OMS Gateway - Event Collection Event 403</td>
<td>Networking error. For example: cannot connect to target server.</td>
</tr>
</tbody>
</table>
&nbsp;

You can download the addon Management Pack over here:

<a href="https://gallery.technet.microsoft.com/SCOM-OMS-Gateway-Addendum-61c0dc18">https://gallery.technet.microsoft.com/SCOM-OMS-Gateway-Addendum-61c0dc18</a>

I've included the VSAE project over here:

<a href="https://msdnshared.blob.core.windows.net/media/2018/04/Microsoft-System-Center-Advisor-Monitoring-Add.zip">VSAE Project</a>

&nbsp;
<h6>Disclaimer:</h6>
<h6>All information on this blog is provided on an as-is basis with no warranties and for informational purposes only. Use at your own risk. The opinions and views expressed in this blog are those of the author and do not necessarily state or reflect those of my employer.</h6>]]></content:encoded>
    </item>
    <item>
      <title>SQL Server 2016 Management Pack - MSSQL 2016: Service Pack Compliance - SP1</title>
      <link>https://docs.microsoft.com/archive/blogs/philipvandevyver/sql-server-2016-management-pack-service-pack-compliance-sp1</link>
      <pubDate>Fri, 05 Jan 2018 14:57:29 GMT</pubDate>
      <dc:creator><![CDATA[Philip Van de Vyver]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/philipvandevyver/?p=505</guid>
      <description><![CDATA[Just a quick update on the SQL Server 2016 Management Pack:

You might have experienced that no...]]></description>
      <content:encoded><![CDATA[Just a quick update on the SQL Server 2016 Management Pack:

You might have experienced that no matter what version of SQL Server Service Pack you install, you get this alert:

<img width="581" height="24" class="alignnone size-full wp-image-506" alt="" src="https://msdnshared.blob.core.windows.net/media/2018/01/SQL2016_SP_Compliance.png" />

<img width="1024" height="578" class="alignnone size-large wp-image-515" alt="" src="https://msdnshared.blob.core.windows.net/media/2018/01/SQL2016_SP_Compliance_1-1024x578.png" />

The reason for this alert is actually not the Management Pack, but the SQL Server installation not updating the registry key.

When looking at the registry key responsible for the SP version, you'll notice that this one isn't updated with the SP version number:

<img width="831" height="441" class="alignnone size-full wp-image-525" alt="" src="https://msdnshared.blob.core.windows.net/media/2018/01/SQL2016_SP_Compliance_2.png" />

A workaround can be to update the registry value to the according SP1 level "1".

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL13.[YourSQLInstanceName]\Setup\SP

Or Override the monitor to either disable it or set 0 as the minimal required SP level.

As stated by the SQL Release team, the issue will be fixed in the next SP2 release for SQL Server 2016:
<a href="https://blogs.msdn.microsoft.com/sqlreleaseservices/released-system-center-management-pack-for-sql-server-and-dashboards-6-7-20-0/">https://blogs.msdn.microsoft.com/sqlreleaseservices/released-system-center-management-pack-for-sql-server-and-dashboards-6-7-20-0/</a>

&nbsp;

Meanwhile, I created a SCOM PowerShell recovery task on the "Service Pack Compliance" Monitor that updates the registry key if necessary for the instance:

<img width="526" height="562" class="alignnone size-full wp-image-536" alt="" src="https://msdnshared.blob.core.windows.net/media/2018/01/SQL2016_SP_Compliance_3.png" />

<img width="513" height="549" class="alignnone size-full wp-image-545" alt="" src="https://msdnshared.blob.core.windows.net/media/2018/01/SQL2016_SP_Compliance_4.png" />

<img width="602" height="549" class="alignnone size-full wp-image-546" alt="" src="https://msdnshared.blob.core.windows.net/media/2018/01/SQL2016_SP_Compliance_5.png" />

&nbsp;
<h4>Download</h4>
"Microsoft SQL Server 2016 (Monitoring) - Addendum - SP1 Recovery" Management Pack:

<a href="https://msdnshared.blob.core.windows.net/media/2018/01/Microsoft.SQL_.Server.Monitoring.Addendum.SP_.Recovery.zip">Microsoft.SQL_.Server.Monitoring.Addendum.SP_.Recovery</a>

&nbsp;

<span>Disclaimer: </span>
<span style="float: none;background-color: transparent;color: #333333;font-family: 'Segoe UI',Tahoma,Arial,'Helvetica Neue',Helvetica,Sans-Serif;font-size: 14px;font-style: normal;font-variant: normal;font-weight: 400;letter-spacing: normal;text-align: left;text-decoration: none;text-indent: 0px"> </span><span>All information on this blog is provided on an as-is basis with no warranties and for informational purposes only. Use at your own risk. The opinions and views expressed in this blog are those of the author and do not necessarily state or reflect those of my employer.</span>

&nbsp;]]></content:encoded>
    </item>
    <item>
      <title>PowerShell Alert Update Connector and Orchestrator</title>
      <link>https://docs.microsoft.com/archive/blogs/philipvandevyver/powershell-alert-update-connector-and-orchestrator</link>
      <pubDate>Fri, 15 Dec 2017 19:00:56 GMT</pubDate>
      <dc:creator><![CDATA[Philip Van de Vyver]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/philipvandevyver/?p=426</guid>
      <description><![CDATA[Many of my customers have the need to "sort" SCOM alerts to different support teams.
In the past,...]]></description>
      <content:encoded><![CDATA[Many of my customers have the need to "sort" SCOM alerts to different support teams.
In the past, the Alert Update Connector was used:
<a href="https://blogs.technet.microsoft.com/kevinholman/2012/09/29/opsmgr-public-release-of-the-alert-update-connector/">https://blogs.technet.microsoft.com/kevinholman/2012/09/29/opsmgr-public-release-of-the-alert-update-connector/</a>
There still are some versions available:
<a href="https://blogs.technet.microsoft.com/markmanty/2017/04/24/scom-alert-update-connector-example-for-scom-2016/">https://blogs.technet.microsoft.com/markmanty/2017/04/24/scom-alert-update-connector-example-for-scom-2016/</a>
<a href="https://blogs.technet.microsoft.com/markmanty/2012/05/03/scom-alert-updater-service-connector-example-updating-scom-alerts/">https://blogs.technet.microsoft.com/markmanty/2012/05/03/scom-alert-updater-service-connector-example-updating-scom-alerts/</a>

The "Supported" way is to use System Center Orchestrator to process your alerts.
For my customer I reused this example:
<a href="https://sc.scomurr.com/scom-2012-flagging-alerts-for-processing-using-scorch-2012-2/">sc.scomurr.com/scom-2012-flagging-alerts-for-processing-using-scorch-2012-2/</a>

&nbsp;

&nbsp;

Here's an overview of what needs to be implemented:
<h2>Alert Enrichment Database and Table</h2>
In order to store the information of each alert. We need to create a database and table. (In my case a CE_Enrichment database and CE_Enrichment table)
The .sql file can be downloaded on the bottom of this article.

The following columns are added to the table:

<img width="173" height="300" class="alignnone wp-image-435 size-medium" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/12/CE_Table-173x300.png" />

&nbsp;

&nbsp;
<h2>Alert Enrichment Configuration Tool</h2>
<h3>Configuration</h3>
In order to get the tool working, we need to define a few settings in the "AE_ConfigurationTool.config" XML:
<ul>
 	<li>RootManagementServerEmulator</li>
 	<li>SQLServer</li>
 	<li>SQLDBName</li>
 	<li>SQLEnrichTable</li>
 	<li>SQLQuery</li>
 	<li>default_appid</li>
 	<li>default_owner</li>
 	<li>default_resstate</li>
 	<li>default_ticket</li>
</ul>
<img width="1024" height="169" class="alignnone size-large wp-image-486" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/12/AE_ConfigTool_Config-1024x169.png" />

&nbsp;

&nbsp;
<h3>The Tool</h3>
I've extended Scott Murray's PowerShell script to do have a similar functionality as the Alert Update Connector.
Multiple SCOM groups can be added to an alert, each group has it's own Custom Field definition.
The advantage of the PowerShell tool is that you can customize the tool anyway you want.
The code is open and there's no need to compile.

The tool can be downloaded on the bottom of this article.

Here's a screenshot of the tool :
<img width="1024" height="881" class="alignnone wp-image-445 size-large" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/12/AE_ConfigTool-1024x881.png" />

&nbsp;

&nbsp;
<h2>System Center Operations Manager</h2>
In order to get the System Center Orchestrator working. We need to create some Resolution States.
In the SCOM Console, goto Administration - Settings - Alerts - Alert Resolution States.
Add the following Resolution States:
<ul>
 	<li>Alert Not SCORH Enriched</li>
 	<li>Alert SCORH Enriched</li>
 	<li>ProcessedBySCORCH</li>
</ul>
<img width="300" height="270" class="alignnone wp-image-446 size-medium" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/12/AE_Resolution-300x270.png" />

&nbsp;
<h2></h2>
<h2></h2>
&nbsp;

&nbsp;
<h2>System Center Orchestrator</h2>
System Center Orchestrator will do the actual job:
<ul>
 	<li>Process Alerts with the Resolution State "New"</li>
 	<li>Set the Resolution State to "ProcessedBySCORCH"</li>
 	<li>Query the Database</li>
 	<li>Check if records for the Rule/Monitor exist in the database
<ul>
 	<li>If exist:
<ul>
 	<li>Run PowerShell script and verify if the MonitoringObject is member of the groups defined in the table</li>
 	<li>Update with corresponding Custom Fields</li>
 	<li>Update Resolution State to "Alert SCORH Enriched"</li>
</ul>
</li>
 	<li>If not exist
<ul>
 	<li>Update Resolution State to "Alert Not SCORH Enriched"</li>
</ul>
</li>
</ul>
</li>
</ul>
Here's the screenshot of the Runbook that processes the alert:

<img width="1024" height="252" class="alignnone wp-image-455 size-large" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/12/AE_Orch-1024x252.png" />

The tool can be downloaded on the bottom of this article.

Because we need to connect to the management group in the PowerShell script we need to import the SCOM module.
Orchestrator 2016 currently has an issue in loading 64bit modules. In order to let Orchestrator import 64bit modules change the following reg. key:

HKLM\SOFTWARE\Wow6432Node\Microsoft\.NETFramework
Reg_DWORD: OnlyUseLatestCLR
Value: 1

Make sure that you know what you are doing before you break backward compatibility:
<a href="https://social.technet.microsoft.com/Forums/lync/en-US/bda22a17-c274-4799-9624-97588fdf4357/orchestrator-2016-powershell-not-importing-modules?forum=scogeneral">https://social.technet.microsoft.com/Forums/lync/en-US/bda22a17-c274-4799-9624-97588fdf4357/orchestrator-2016-powershell-not-importing-modules?forum=scogeneral
</a><a href="https://www.opsconfig.com/better-practices-orchestrator-automation-sometimes-that-blog-post-that-seems-too-good-to-be-true/">www.opsconfig.com/better-practices-orchestrator-automation-sometimes-that-blog-post-that-seems-too-good-to-be-true/</a>

&nbsp;

&nbsp;
<h3><strong>Download:</strong></h3>
The Alert Enrichment Configuration tool:

<a href="https://msdnshared.blob.core.windows.net/media/2018/01/AE_ConfigurationTool_v2_0_8.zip">AE_ConfigurationTool_v2_0_8</a>

The Orchestrator Runbook:

<a href="https://msdnshared.blob.core.windows.net/media/2018/01/2.8-AUC.zip">2.8-AUC</a>

SQL create Enrichment Table:

<a href="https://msdnshared.blob.core.windows.net/media/2018/01/CE_Enrichment.zip">CE_Enrichment</a>

&nbsp;

&nbsp;

<span>Disclaimer: </span>
<span>All information on this blog is provided on an as-is basis with no warranties and for informational purposes only. Use at your own risk. The opinions and views expressed in this blog are those of the author and do not necessarily state or reflect those of my employer.</span>]]></content:encoded>
    </item>
    <item>
      <title>Undiscovering / Stop Monitoring SQL 2008/2012/2014/2016 Express Editions</title>
      <link>https://docs.microsoft.com/archive/blogs/philipvandevyver/undiscovering-stop-monitoring-sql-2008201220142016-express-editions</link>
      <pubDate>Tue, 07 Nov 2017 11:38:59 GMT</pubDate>
      <dc:creator><![CDATA[Philip Van de Vyver]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/philipvandevyver/?p=356</guid>
      <description><![CDATA[This post is an update...]]></description>
      <content:encoded><![CDATA[This post is an update of <a href="https://blogs.technet.microsoft.com/emreguclu/2014/09/12/undiscovering-stop-monitoring-sql-200520082012-express-editions/">https://blogs.technet.microsoft.com/emreguclu/2014/09/12/undiscovering-stop-monitoring-sql-200520082012-express-editions/</a> which adds SQL 2014 and SQL 2016 and removes SQL 2005 support to existing mp as per requests of customers.
If you have the older version please just download and import this one.

For all details about the configuration of the Management Pack, please visit Emre's Blog.

MP Download:
<a href="https://msdnshared.blob.core.windows.net/projects/SQLExpress.RemoveMP.xml">SQLExpress.RemoveMP.xml</a>

&nbsp;]]></content:encoded>
    </item>
    <item>
      <title>Healthservice Service SID Type</title>
      <link>https://docs.microsoft.com/archive/blogs/philipvandevyver/healthservice-service-sid-type</link>
      <pubDate>Mon, 29 May 2017 21:48:01 GMT</pubDate>
      <dc:creator><![CDATA[Philip Van de Vyver]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/philipvandevyver/?p=365</guid>
      <description><![CDATA[Hi,

While visiting customers, I'm often asked how to configure RunAs accounts for the SQL...]]></description>
      <content:encoded><![CDATA[Hi,

While visiting customers, I'm often asked how to configure RunAs accounts for the SQL Management Pack.
I love the new way using the Healthservice Service SID as Kevin Holman documented in his blog post over here: <a href="https://blogs.technet.microsoft.com/kevinholman/2016/08/25/sql-mp-run-as-accounts-no-longer-required-2/">https://blogs.technet.microsoft.com/kevinholman/2016/08/25/sql-mp-run-as-accounts-no-longer-required-2/</a>

I don't want to go over the configuration of his Management Pack again. I just want to show on how you can query the Healthservice SID setting.

&nbsp;

Let's start:

&nbsp;

We're using the <strong>SC.EXE</strong> tool to set the SID type for the Healthservice.
For more information on Windows Service Hardening, take a look over here: <a href="https://blogs.technet.microsoft.com/askperf/2008/02/03/ws2008-windows-service-hardening/">https://blogs.technet.microsoft.com/askperf/2008/02/03/ws2008-windows-service-hardening/</a>

&nbsp;

To set the SID type to unrestricted, we use the following command:
<code>sc sidtype HealthService unrestricted
</code>Showing the following output:
<img width="508" height="54" class="alignnone size-full wp-image-405" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/05/sc_sidtype_healthservice_UNRESTRICTED.png" />

That's it, you can use the Service SID of the Healthservice as a logon in SQL Server

&nbsp;

What the command does, is changing the value of the registry key: "<em>HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\HealthService\ServiceSidType</em>" to 1:

<img width="1824" height="508" class="alignnone size-full wp-image-406" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/05/ServiceSidTypeReg.png" />

&nbsp;

&nbsp;

You can use the following commands to get more information of the Healthservice SID type setting:

&nbsp;

<code>sc qsidtype healthservice</code>

<code>
</code>An example of an <strong>unconfigured</strong> "<em><strong>NONE</strong></em>" SID type:<code>
</code><img width="387" height="144" class="alignnone size-full wp-image-375" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/05/sc_qsidtype_none.png" />

An example of a <strong>configured</strong> "<em><strong>UNRESTRICTED</strong></em>" SID type:
<img width="385" height="135" class="alignnone size-full wp-image-377" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/05/sc_qsidtype_UNRESTRICTED.png" />

&nbsp;

&nbsp;

<code>sc showsid healthservice</code>

<code>
</code>An example of an <strong>unconfigured</strong> "<em><strong>Inactive</strong></em>" status: <img width="879" height="136" class="alignnone size-full wp-image-395" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/05/sc_showsid_inactive.png" />

An example of a <strong>configured</strong> "<em><strong>Active</strong></em>" status:<img width="908" height="139" class="alignnone size-full wp-image-385" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/05/sc_showsid_active.png" />

&nbsp;

&nbsp;

This wil hopefully point you in the right direction when verifying the Healthservice Service SID.

&nbsp;]]></content:encoded>
    </item>
    <item>
      <title>SCOM Environment Classification</title>
      <link>https://docs.microsoft.com/archive/blogs/philipvandevyver/scom-environment-classification</link>
      <pubDate>Thu, 27 Apr 2017 13:56:27 GMT</pubDate>
      <dc:creator><![CDATA[Philip Van de Vyver]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/philipvandevyver/?p=176</guid>
      <description><![CDATA[I often hear from customers that they are connecting all there Environments (Test, Acceptance,...]]></description>
      <content:encoded><![CDATA[I often hear from customers that they are connecting all there Environments (Test, Acceptance, Production) to one SCOM environment.
As expected, SCOM will generate alerts for all environments without making a difference between the environment.

Customers are asking if we can split up the Environment monitoring in the SCOM console.
A sollution could be making manual groups for each of the class types or Windows Computer objects.

I try to avoid manual work and maintenance, therefore I  developed the following Management Pack in order to classify:
<ul>
 	<li>Windows Computer Objects</li>
 	<li>Other Objects from other classes</li>
</ul>
Here's a high level overview of what the Management Pack does:
<ol>
 	<li>Create new Class "Windows Computer Environment Class" with "Windows Computer" as the base class and polulate Class with all "Windows Computer" objects and add a discoverd registry property "Environment" based on a Registry Key.</li>
 	<li>Create Groups for each environment (Test, Acceptance, Production) and populate them with "Windows Computer" Objects.</li>
 	<li>Create Groups for each environment (Test, Acceptance, Production) and Class and populate the with the instances of the class selected.</li>
</ol>
I will use Visual Studio 2015 with Authoring Extensions (VSAE) to  develop the Management Pack. (available here: <a href="https://www.microsoft.com/en-us/download/details.aspx?id=30169">https://www.microsoft.com/en-us/download/details.aspx?id=30169</a>)
VSAE has the advantage to work with "Snippets".  I will be using them in order to simplify the development and to reproduce XML data.
Don't be afraid of using Visual Studio, it's a great tool to develop Management Packs.

<hr />

Let's  go :
<h2>Create new Class "Windows Computer Environment Class" with "Windows Computer" as the base class and polulate Class with all "Windows Computer" objects and add a discoverd registry property "Environment" based on a Registry Key.</h2>
Let's start by creating a new Visual Studio Project:

<img width="1649" height="1144" class="alignnone size-full wp-image-205" alt="creatempproject" src="https://msdnshared.blob.core.windows.net/media/2017/04/CreateMPProject.bmp" />

Add a new reference (Microsoft.SystemCenter.InstanceGroup.library.mp) can be found on the SCOM install media "ManagementPacks" folder:

<img width="1094" height="993" class="alignnone size-full wp-image-195" alt="addnewreference" src="https://msdnshared.blob.core.windows.net/media/2017/04/AddNewReference.bmp" />

Create a new Class Windows Computer Environment:

<img width="1649" height="1144" class="alignnone size-full wp-image-185" alt="addnewclass" src="https://msdnshared.blob.core.windows.net/media/2017/04/AddNewClass.bmp" />

Here's the XML of the Class, creating the Class "Environment.Windows_Computer_Environment" with "Microsoft.Windows.Computer" as a base class and with a property "Environment.Windows_Computer_EnvironmentProperty".

<code>&lt;ManagementPackFragment SchemaVersion="2.0" xmlns:xsd="https://www.w3.org/2001/XMLSchema"&gt;</code>
<code>  &lt;TypeDefinitions&gt;</code>
<code>    &lt;EntityTypes&gt;</code>
<code>      &lt;ClassTypes&gt;</code>
<code>        &lt;ClassType ID="Environment.Windows_Computer_Environment" Accessibility="Public" Abstract="false" Base="Windows!Microsoft.Windows.Computer" Hosted="false" Singleton="false" Extension="false"&gt;</code>
<code>          &lt;Property ID="Environment.Windows_Computer_Environment.EnvironmentProperty" Type="string" AutoIncrement="false" Key="false" CaseSensitive="false" MaxLength="256" MinLength="0" Required="false" Scale="0" /&gt;</code>
<code>        &lt;/ClassType&gt;    </code>
<code>      &lt;/ClassTypes&gt;</code>
<code>    &lt;/EntityTypes&gt;</code>
<code>  &lt;/TypeDefinitions&gt;</code>
<code>  &lt;LanguagePacks&gt;</code>
<code>    &lt;LanguagePack ID="ENU" IsDefault="true"&gt;</code>
<code>      &lt;DisplayStrings&gt;</code>
<code>        &lt;DisplayString ElementID="Environment.Windows_Computer_Environment"&gt;</code>
<code>          &lt;Name&gt;Windows Computer Environment Class&lt;/Name&gt;</code>
<code>          &lt;Description&gt;&lt;/Description&gt;</code>
<code>        &lt;/DisplayString&gt;</code>
<code>        &lt;DisplayString ElementID="Environment.Windows_Computer_Environment" SubElementID="Environment.Windows_Computer_Environment.EnvironmentProperty"&gt;</code>
<code>          &lt;Name&gt;Environment&lt;/Name&gt;</code>
<code>          &lt;Description /&gt;</code>
<code>        &lt;/DisplayString&gt;</code>
<code>      &lt;/DisplayStrings&gt;</code>
<code>    &lt;/LanguagePack&gt;</code>
<code>  &lt;/LanguagePacks&gt;</code>
<code>&lt;/ManagementPackFragment&gt;</code>

&nbsp;

Add new Discovery "Windows Computer Environment Discovery" :

<img width="941" height="649" class="alignnone size-full wp-image-235" alt="newdiscovery" src="https://msdnshared.blob.core.windows.net/media/2017/04/NewDiscovery1.png" />

Change the Discovery with following Properties:

<a href="https://msdnshared.blob.core.windows.net/media/2017/04/Discovery_1.bmp"><img width="838" height="94" class="alignnone size-full wp-image-245" alt="discovery_1" src="https://msdnshared.blob.core.windows.net/media/2017/04/Discovery_1.bmp" /></a>

<img width="921" height="452" class="alignnone size-full wp-image-255" alt="discovery_2" src="https://msdnshared.blob.core.windows.net/media/2017/04/Discovery_2.bmp" />

Here's the XML from the "Configuration XML" Property.
The discovery will look for a registry key "SYSTEM\Configuration\Environment" and will populate the value in the "Environment" Property of the "Windows Computer Environment" Class:

<code>&lt;?xml version="1.0" encoding="utf-8"?&gt;</code>
<code>&lt;Configuration xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="https://www.w3.org/2001/XMLSchema" xsi:noNamespaceSchemaLocation="C:\Users\phvandev\AppData\Local\Temp\tmp4E2C.tmp"&gt;</code>
<code>  &lt;ComputerName&gt;$Target/Property[Type="Windows!Microsoft.Windows.Computer"]/NetworkName$&lt;/ComputerName&gt;</code>
<code>  &lt;AttributeName&gt;Environment.Windows_Computer_Environment.EnvironmentPropertyRule&lt;/AttributeName&gt;</code>
<code>  &lt;Path&gt;SYSTEM\Configuration\Environment&lt;/Path&gt;</code>
<code>  &lt;PathType&gt;1&lt;/PathType&gt;</code>
<code>  &lt;AttributeType&gt;1&lt;/AttributeType&gt;</code>
<code>  &lt;Frequency&gt;86000&lt;/Frequency&gt;</code>
<code>  &lt;ClassId&gt;$MPElement[Name="Environment.Windows_Computer_Environment"]$&lt;/ClassId&gt;</code>
<code>  &lt;InstanceSettings&gt;</code>
<code>    &lt;Settings&gt;</code>
<code>      &lt;Setting&gt;</code>
<code>        &lt;Name&gt;$MPElement[Name="Environment.Windows_Computer_Environment"]/Environment.Windows_Computer_Environment.EnvironmentProperty$&lt;/Name&gt;</code>
<code>        &lt;Value&gt;$Data/Values/Environment.Windows_Computer_Environment.EnvironmentPropertyRule$&lt;/Value&gt;</code>
<code>      &lt;/Setting&gt;</code>
<code>      &lt;Setting&gt;</code>
<code>        &lt;Name&gt;$MPElement[Name="Windows!Microsoft.Windows.Computer"]/PrincipalName$&lt;/Name&gt;</code>
<code>        &lt;Value&gt;$Target/Property[Type="Windows!Microsoft.Windows.Computer"]/PrincipalName$&lt;/Value&gt;</code>
<code>      &lt;/Setting&gt;</code>
<code>    &lt;/Settings&gt;</code>
<code>  &lt;/InstanceSettings&gt;</code>
<code>&lt;/Configuration&gt;</code>

This is the will finilize of the configuration of the "Windows Computer Environment" Class with the Property "Environment".

The overall configuration of you Visual Studio Solution should more or less looking as follow:
<img width="485" height="419" class="alignnone size-full wp-image-265" alt="overview_1" src="https://msdnshared.blob.core.windows.net/media/2017/04/Overview_1.bmp" />

After you import the Management Pack, you can see the property "Environment" when you use the "Discovered Inventory" view Targetted to "Windows Computer Environment"

<img width="1644" height="319" class="alignnone size-full wp-image-275" alt="discovered-inverntory" src="https://msdnshared.blob.core.windows.net/media/2017/04/Discovered-inverntory.png" />

&nbsp;
<h2></h2>
<h2></h2>
<h2></h2>
<h2>Create Groups for each environment (Test, Acceptance, Production) and populate them with "Windows Computer" Objects.</h2>
For this part I will use Visual Studio Snippets to reproduce XML data for each environment.

Create a new Snippet Template called "Environment Group.templatesnippet":

<img width="941" height="649" class="alignnone size-full wp-image-285" alt="snippettemplate" src="https://msdnshared.blob.core.windows.net/media/2017/04/SnippetTemplate.png" />

Here's the XML from the Snippet Template

The XML will:
<ul>
 	<li>Create a class for the Environment Group</li>
 	<li>Populate the class with members that have a specific Environment Property.</li>
</ul>
Note that I use the following variables:
<ul>
 	<li><em>#text('EnvironmentName')#</em> (Used as variable for the environment)</li>
 	<li><em>#alias('managementpackname')#</em> (Used to get the alias of the referenced Management Pack)</li>
</ul>
<div><code>&lt;ManagementPackFragment SchemaVersion="2.0"&gt;</code>
<code>    &lt;TypeDefinitions&gt;</code>
<code>      &lt;EntityTypes&gt;</code>
<code>        &lt;ClassTypes&gt;</code>
<code>          &lt;ClassType ID="Environment.#text('EnvironmentName')#.Group" Accessibility="Public" Abstract="false" Base="#alias('Microsoft.SystemCenter.InstanceGroup.Library')#!Microsoft.SystemCenter.InstanceGroup" Hosted="false" Singleton="true" Extension="false" /&gt;</code>
<code>        &lt;/ClassTypes&gt;</code>
<code>      &lt;/EntityTypes&gt;</code>
<code>    &lt;/TypeDefinitions&gt;</code>
<code>  &lt;Monitoring&gt;</code>
<code>    &lt;Discoveries&gt;</code>
<code>      &lt;Discovery ID="Environment.#text('EnvironmentName')#.Group.DiscoveryRule" Enabled="true" Target="Environment.#text('EnvironmentName')#.Group" ConfirmDelivery="false" Remotable="true" Priority="Normal"&gt;</code>
<code>        &lt;Category&gt;Discovery&lt;/Category&gt;</code>
<code>        &lt;DiscoveryTypes&gt;</code>
<code>          &lt;DiscoveryRelationship TypeID="#alias('Microsoft.SystemCenter.InstanceGroup.Library')#!Microsoft.SystemCenter.InstanceGroupContainsEntities" /&gt;</code>
<code>        &lt;/DiscoveryTypes&gt;</code>
<code>        &lt;DataSource ID="GroupPopulationDataSource" TypeID="#alias('Microsoft.SystemCenter.Library')#!Microsoft.SystemCenter.GroupPopulator"&gt;</code>
<code>          &lt;RuleId&gt;$MPElement$&lt;/RuleId&gt;</code>
<code>          &lt;GroupInstanceId&gt;$MPElement[Name="Environment.#text('EnvironmentName')#.Group"]$&lt;/GroupInstanceId&gt;</code>
<code>          &lt;MembershipRules&gt;</code>
<code>            &lt;MembershipRule&gt;</code>
<code>              &lt;MonitoringClass&gt;$MPElement[Name="Environment.Windows_Computer_Environment"]$&lt;/MonitoringClass&gt;</code>
<code>              &lt;RelationshipClass&gt;$MPElement[Name="#alias('Microsoft.SystemCenter.InstanceGroup.Library')#!Microsoft.SystemCenter.InstanceGroupContainsEntities"]$&lt;/RelationshipClass&gt;</code>
<code>              &lt;Expression&gt;</code>
<code>                &lt;SimpleExpression&gt;</code>
<code>                  &lt;ValueExpression&gt;</code>
<code>                    &lt;Property&gt;$MPElement[Name="Environment.Windows_Computer_Environment"]/Environment.Windows_Computer_Environment.EnvironmentProperty$&lt;/Property&gt;</code>
<code>                  &lt;/ValueExpression&gt;</code>
<code>                  &lt;Operator&gt;Equal&lt;/Operator&gt;</code>
<code>                  &lt;ValueExpression&gt;</code>
<code>                    &lt;Value&gt;#text('EnvironmentName')#&lt;/Value&gt;</code>
<code>                  &lt;/ValueExpression&gt;</code>
<code>                &lt;/SimpleExpression&gt;</code>
<code>              &lt;/Expression&gt;</code>
<code>            &lt;/MembershipRule&gt;</code>
<code>          &lt;/MembershipRules&gt;</code>
<code>        &lt;/DataSource&gt;</code>
<code>      &lt;/Discovery&gt;</code>
<code>    &lt;/Discoveries&gt;</code>
<code>  &lt;/Monitoring&gt;</code>
<code>    </code>
<code>    &lt;LanguagePacks&gt;</code>
<code>      &lt;LanguagePack ID="ENU" IsDefault="true"&gt;</code>
<code>        &lt;DisplayStrings&gt;</code>
<code>          &lt;DisplayString ElementID="Environment.#text('EnvironmentName')#.Group"&gt;</code>
<code>            &lt;Name&gt;Environment - #text('EnvironmentName')#&lt;/Name&gt;</code>
<code>          &lt;/DisplayString&gt;</code></div>
<div><code>        &lt;DisplayString ElementID="Environment.#text('EnvironmentName')#.Group.DiscoveryRule"&gt;</code>
<code>          &lt;Name&gt;Populate Environment - #text('EnvironmentName')#&lt;/Name&gt;</code>
<code>          &lt;Description&gt;This discovery rule populates the group 'Environment - #text('EnvironmentName')# '&lt;/Description&gt;</code>
<code>        &lt;/DisplayString&gt;</code>
<code>        &lt;/DisplayStrings&gt;</code>
<code>      &lt;/LanguagePack&gt;</code>
<code>    &lt;/LanguagePacks&gt;</code></div>
<div><code>  &lt;/ManagementPackFragment&gt;</code></div>
&nbsp;

Next would be creating the Snippet Data where we reference the created Snippet Template ("Environment Group"):

<img width="941" height="649" class="alignnone size-full wp-image-286" alt="snippet-data" src="https://msdnshared.blob.core.windows.net/media/2017/04/Snippet-Data.png" />

You now can define the variables used for the Snippet Template (in this case only EnvironmentName is used).
Simply enter the Environment names for all environments. By doing this you will reproduce the XML for each defined Environment variable.
This is showing how easy and fast you can develop parts of a Management Pack.

<img width="1290" height="194" class="alignnone size-full wp-image-295" alt="snippet-data-properties" src="https://msdnshared.blob.core.windows.net/media/2017/04/Snippet-Data-Properties.png" />

The overall configuration of you Visual Studio Solution should more or less looking as follow:

<img width="482" height="597" class="alignnone size-full wp-image-305" alt="overview_2" src="https://msdnshared.blob.core.windows.net/media/2017/04/Overview_2.bmp" />

When you import the Management Pack you should see 3 groups created, one for each created environment (TST, ACC, PROD):
<ul>
 	<li>Environment - TST</li>
 	<li>Environment - ACC</li>
 	<li>Environment - PROD</li>
</ul>
<h2></h2>
<h2></h2>
<h2></h2>
<h2>Create Groups for each environment (Test, Acceptance, Production) and Class and populate the with the instances of the class selected.</h2>
Also for this part I will use Visual Studio Snippets to reproduce XML data for each environment.

Create a new Snippet Template called "Environment Instance Group.templatesnippet" as shown earlier.

Here's the XML of the Snippet Template.

Note that I use the following variables:
<ul>
 	<li>#text('EnvironmentName')# (Used as variable for the environment)</li>
 	<li>#text('InstanceClass')# (Used as variable for the Instance Class we are selecting)</li>
 	<li>#text('InstanceClassMPAlias')#  (Used as variable for the Alias of the Management Pack that holds Instance Class that we are selecting)</li>
 	<li>#alias('managementpackname')# (Used to get the alias of the referenced Management Pack)</li>
</ul>
<code>&lt;ManagementPackFragment SchemaVersion="2.0"&gt;</code>
<code> &lt;TypeDefinitions&gt;</code>
<code> &lt;EntityTypes&gt;</code>
<code> &lt;ClassTypes&gt;</code>
<code> &lt;ClassType ID="Environment.#text('EnvironmentName')#.#text('InstanceClass')#.Group" Accessibility="Public" Abstract="false" Base="#alias('Microsoft.SystemCenter.InstanceGroup.Library')#!Microsoft.SystemCenter.InstanceGroup" Hosted="false" Singleton="true" Extension="false"&gt;&lt;/ClassType&gt;</code>
<code> &lt;/ClassTypes&gt;</code>
<code> &lt;/EntityTypes&gt;</code>

<code> &lt;/TypeDefinitions&gt;</code>
<code> &lt;Monitoring&gt;</code>
<code> &lt;Discoveries&gt;</code>
<code> &lt;Discovery ID="Environment.#text('EnvironmentName')#.#text('InstanceClass')#.Group.DiscoveryRule" Enabled="true" Target="Environment.#text('EnvironmentName')#.#text('InstanceClass')#.Group" ConfirmDelivery="false" Remotable="true" Priority="Normal"&gt;</code>
<code> &lt;Category&gt;Discovery&lt;/Category&gt;</code>
<code> &lt;DiscoveryTypes&gt;</code>
<code> &lt;DiscoveryRelationship TypeID="#alias('Microsoft.SystemCenter.InstanceGroup.Library')#!Microsoft.SystemCenter.InstanceGroupContainsEntities" /&gt;</code>
<code> &lt;/DiscoveryTypes&gt;</code>
<code> &lt;DataSource ID="GroupPopulationDataSource" TypeID="#alias('Microsoft.SystemCenter.Library')#!Microsoft.SystemCenter.GroupPopulator"&gt;</code>
<code> &lt;RuleId&gt;$MPElement$&lt;/RuleId&gt;</code>
<code> &lt;GroupInstanceId&gt;$MPElement[Name="Environment.#text('EnvironmentName')#.#text('InstanceClass')#.Group"]$&lt;/GroupInstanceId&gt;</code>
<code> &lt;MembershipRules&gt;</code>
<code> &lt;MembershipRule&gt;</code>
<code> &lt;MonitoringClass&gt;$MPElement[Name="#text('InstanceClassMPAlias')#!#text('InstanceClass')#"]$&lt;/MonitoringClass&gt;</code>
<code> &lt;RelationshipClass&gt;$MPElement[Name="#alias('Microsoft.SystemCenter.InstanceGroup.Library')#!Microsoft.SystemCenter.InstanceGroupContainsEntities"]$&lt;/RelationshipClass&gt;</code>
<code> &lt;Expression&gt;</code>
<code> &lt;Contained maxDepth="2"&gt;</code>
<code> &lt;MonitoringClass&gt;$MPElement[Name="Environment.#text('EnvironmentName')#.Group"]$&lt;/MonitoringClass&gt;</code>
<code> &lt;/Contained&gt;</code>
<code> &lt;/Expression&gt;</code>
<code> &lt;/MembershipRule&gt;</code>
<code> &lt;/MembershipRules&gt;</code>
<code> &lt;/DataSource&gt;</code>
<code> &lt;/Discovery&gt;</code>
<code> &lt;/Discoveries&gt;</code>
<code> &lt;/Monitoring&gt;</code>

<code>&lt;LanguagePacks&gt;</code>
<code> &lt;LanguagePack ID="ENU" IsDefault="true"&gt;</code>
<code> &lt;DisplayStrings&gt;</code>
<code> &lt;DisplayString ElementID="Environment.#text('EnvironmentName')#.#text('InstanceClass')#.Group.DiscoveryRule"&gt;</code>
<code> &lt;Name&gt;Environment - #text('EnvironmentName')# - #text('InstanceClass')# Group Populator&lt;/Name&gt;</code>
<code> &lt;Description&gt;This discovery rule populates the group 'Environment - #text('EnvironmentName')# - #text('InstanceClass')#'&lt;/Description&gt;</code>
<code> &lt;/DisplayString&gt;</code>
<code> &lt;DisplayString ElementID="Environment.#text('EnvironmentName')#.#text('InstanceClass')#.Group"&gt;</code>
<code> &lt;Name&gt;Environment - #text('EnvironmentName')# - #text('InstanceClass')#&lt;/Name&gt;</code>
<code> &lt;/DisplayString&gt;</code>
<code> &lt;/DisplayStrings&gt;</code>
<code> &lt;/LanguagePack&gt;</code>
<code> &lt;/LanguagePacks&gt;</code>
<code>&lt;/ManagementPackFragment&gt;</code>

Create new Snippet Data called "Environment Instance Groups.mpsd" and reference the Snippet Template "Environment Instance Group" created in previous step.

For this example I'll use the "Microsoft.Windows.Server.10.0.OperatingSystem" Class from the "Microsoft.Windows.Server.2016.Discovery" Management Pack (Windows Server 2016 Operating System) and populate all instance from a particular Environment to a Group.
Therefore, we need to create a new reference to the "Microsoft.Windows.Server.2016.Discovery" Management Pack:
<img width="477" height="280" class="alignnone size-full wp-image-325" alt="ws2016ref" src="https://msdnshared.blob.core.windows.net/media/2017/04/WS2016Ref.png" />

Note the Alias for the Management Pack in the Properties of the Management Pack:
<img width="481" height="238" class="alignnone size-full wp-image-326" alt="ws2016refproperties" src="https://msdnshared.blob.core.windows.net/media/2017/04/WS2016RefProperties.png" />

Next would be creating the Snippet Data where we reference the created Snippet Template ("Environment Instance Group") as shown earlier.

You now can use the variables used for the Snippet Template (EnvironmentName, InstanceClass, InstanceClassMPAlias)
<ul>
 	<li>EnvironmentName (The Environment Variable we defined earlier (TST, ACC, PROD)</li>
 	<li>InstanceClass (The Class that we select to populate the group with, for this example we'll use "Microsoft.Windows.Server.10.0.OperatingSystem")</li>
 	<li>InstanceClassMPAlias (The Management Pack Alias for the Management Pack that holds the class, for this example we'll use "MWS2016")</li>
</ul>
By doing this you will reproduce the XML for each defined variable set.

<img width="1293" height="175" class="alignnone size-full wp-image-335" alt="snippet-data2" src="https://msdnshared.blob.core.windows.net/media/2017/04/Snippet-Data2.png" />

This will end the configuration of the Management Pack.

When you import the Management Pack, you'll see the following Groups created:

<img width="928" height="372" class="alignnone size-full wp-image-345" alt="groups" src="https://msdnshared.blob.core.windows.net/media/2017/04/Groups.png" />

The "Environment - PROD - Microsoft Windows Server 10.0.OperatingSystem" will show all production Windows Server 2016 Operating System Objects:

<img width="1471" height="220" class="alignnone size-full wp-image-355" alt="group_members" src="https://msdnshared.blob.core.windows.net/media/2017/04/Group_Members.png" />

You can now use these groups to build dashboards or other purposes.

&nbsp;

Here's the Visual Studio Project:

<a href="https://msdnshared.blob.core.windows.net/projects/Environment.zip">https://msdnshared.blob.core.windows.net/projects/Environment.zip</a>

&nbsp;

Here's the Management Pack XML:

<a href="https://msdnshared.blob.core.windows.net/projects/Environment.xml">https://msdnshared.blob.core.windows.net/projects/Environment.xml</a>

&nbsp;

&nbsp;]]></content:encoded>
    </item>
  </channel>
</rss>