<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.technet.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>BWren's Management Space : Management Packs</title><link>http://blogs.technet.com/brianwren/archive/tags/Management+Packs/default.aspx</link><description>Tags: Management Packs</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>SNMP Queries</title><link>http://blogs.technet.com/brianwren/archive/2009/01/21/snmp-queries.aspx</link><pubDate>Wed, 21 Jan 2009 19:22:35 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3188530</guid><dc:creator>Brian Wren</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.technet.com/brianwren/comments/3188530.aspx</comments><wfw:commentRss>http://blogs.technet.com/brianwren/commentrss.aspx?PostID=3188530</wfw:commentRss><description>&lt;p&gt;I recently help someone out getting a monitor working that uses the System.SnmpQueryProvider module in the System.Snmp.Library management pack to perform a query against an SNMP device.&amp;#160; They were getting back an error message showing some cryptic characters in the community string.&amp;#160; They were just providing simple text like &amp;quot;public&amp;quot; for the CommunityString parameter on the module, so this looked pretty strange.&lt;/p&gt;  &lt;p&gt;After some research, it turns out that module wants the community string specified in Base64 format.&amp;#160; Nothing special from the MP perspective – you just need to specify the Base64 equivalent of your community string in the CommunityString parameter rather than the simple text.&lt;/p&gt;  &lt;p&gt;If you already have a means of converting a string to Base64, then you should be fine.&amp;#160; If not, here’s bit of PowerShell that will do the conversion for you.&lt;/p&gt;  &lt;pre class="csharpcode"&gt;$communityString = &lt;span class="str"&gt;'public'&lt;/span&gt;
[System.Convert]::ToBase64String([System.Text.Encoding]::UNICODE.GetBytes($communityString))&lt;/pre&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;If I run that code, I get the following value: cAB1AGIAbABpAGMA.&amp;#160; Pasting that into the CommunityString parameter on the module should get you the results you want.&amp;#160; Obviously, if you have a community name different than &amp;quot;public&amp;quot; you would paste that in and use the resulting converted value.&lt;/p&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3188530" width="1" height="1"&gt;</description><category domain="http://blogs.technet.com/brianwren/archive/tags/OpsMgr/default.aspx">OpsMgr</category><category domain="http://blogs.technet.com/brianwren/archive/tags/Management+Packs/default.aspx">Management Packs</category></item><item><title>Update to the Maintenance Mode Sample MP</title><link>http://blogs.technet.com/brianwren/archive/2008/03/10/update-to-the-maintenance-mode-sample-mp.aspx</link><pubDate>Mon, 10 Mar 2008 17:59:32 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:2984104</guid><dc:creator>Brian Wren</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.technet.com/brianwren/comments/2984104.aspx</comments><wfw:commentRss>http://blogs.technet.com/brianwren/commentrss.aspx?PostID=2984104</wfw:commentRss><description>&lt;p&gt;Andrzej Lipka, a fellow consultant in Poland, took my &lt;a href="http://blogs.technet.com/brianwren/archive/2008/02/28/scheduling-groups-of-objects-for-maintenance-mode.aspx"&gt;maintenance mode sample MP&lt;/a&gt; and added some interesting features.&amp;nbsp; Have a look at the specific post &lt;a href="http://blogs.technet.com/alipka/archive/2008/03/10/opsmgr-modified-brian-s-scheduled-maintenance-mode-mp.aspx"&gt;here&lt;/a&gt;.&amp;nbsp; I also added a link to Andrzej's blog to my general list since he has some great posts on OpsMgr and SCCM.&lt;/p&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=2984104" width="1" height="1"&gt;</description><category domain="http://blogs.technet.com/brianwren/archive/tags/OpsMgr/default.aspx">OpsMgr</category><category domain="http://blogs.technet.com/brianwren/archive/tags/Management+Packs/default.aspx">Management Packs</category></item><item><title>Using Wildcards with the Windows Service Template</title><link>http://blogs.technet.com/brianwren/archive/2008/03/07/using-wildcards-with-the-windows-service-template.aspx</link><pubDate>Sat, 08 Mar 2008 10:25:20 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:2977707</guid><dc:creator>Brian Wren</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.technet.com/brianwren/comments/2977707.aspx</comments><wfw:commentRss>http://blogs.technet.com/brianwren/commentrss.aspx?PostID=2977707</wfw:commentRss><description>&lt;p&gt;The Windows Service template in the Operations Console lets you discover and monitor a Windows service by doing little more than typing in the service name.&amp;nbsp; I was just talking with someone who had a situation where the name of the service includes the local computer name meaning that it's different on every computer.&amp;nbsp; It's the same service and should be monitored as such - just a slightly different name on each agent.&amp;nbsp; Unfortunately, the template won't allow us to provide a wildcard in the service name.&amp;nbsp; &lt;/p&gt; &lt;p&gt;For those who are skilled with management pack authoring, you're probably not relying on the template anyway, and this wouldn't be too difficult of a task.&amp;nbsp; As such, I'm going to write this post from the point of view of someone who primarily lives within the Operations Console.&amp;nbsp; We do have to get exposed to a bit of XML in order to pull this off, but it really should be minimal.&lt;/p&gt; &lt;p&gt;First, let's understand what the Windows Service template does.&amp;nbsp; It performs two functions: 1) creates a new class (aka target) for your service and 2) creates a discovery to find instances of that new class.&amp;nbsp; The new class that the template created should be fine as is.&amp;nbsp; We can provide the template with any name we want, and it doesn't have to have anything to do with the name of the service itself.&amp;nbsp; The discovery is what we need to think about.&lt;/p&gt; &lt;p&gt;The discovery that the template uses is a special one specifically designed for finding a service, and it doesn't allow wildcards.&amp;nbsp; We can replace that discovery with a WMI discovery module since we can pretty easily write a WMI query to find all services that match a certain criteria, and that criteria can include a wildcard.&amp;nbsp; There is a module called WmiProviderWithClassSnapshotDataMapper in the Windows Library management pack that will work perfectly.&lt;/p&gt; &lt;p&gt;Let's go through this step by step.&amp;nbsp; I have a virtual machine running under the beta of Hyper-V in Windows Server 2008.&amp;nbsp; That includes a few services that start with the three letters "vmi".&amp;nbsp; I know this is a bit of a difference scenario than I described above, but it will still illustrate the point of discovering services using a wildcard.&amp;nbsp; &lt;/p&gt; &lt;p&gt;1.&amp;nbsp; Walk through the Windows Template wizard as normal providing your wildcard string.&amp;nbsp; Note that we are going to pass this off to WMI which uses % as a wildcard character, not *.&lt;/p&gt; &lt;p align="center"&gt;&lt;a href="http://blogs.technet.com/blogfiles/brianwren/WindowsLiveWriter/UsingWildcardswiththeWindowsServiceTempl_F7C9/image_8.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="423" alt="image" src="http://blogs.technet.com/blogfiles/brianwren/WindowsLiveWriter/UsingWildcardswiththeWindowsServiceTempl_F7C9/image_thumb_3.png" width="492" border="0"&gt;&lt;/a&gt;&amp;nbsp;&lt;a href="http://blogs.technet.com/blogfiles/brianwren/WindowsLiveWriter/UsingWildcardswiththeWindowsServiceTempl_F7C9/image_10.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="423" alt="image" src="http://blogs.technet.com/blogfiles/brianwren/WindowsLiveWriter/UsingWildcardswiththeWindowsServiceTempl_F7C9/image_thumb_4.png" width="492" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;2.&amp;nbsp; Export the management pack you just used for the template.&lt;/p&gt; &lt;p align="center"&gt;&lt;a href="http://blogs.technet.com/blogfiles/brianwren/WindowsLiveWriter/UsingWildcardswiththeWindowsServiceTempl_F7C9/image_2.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="369" alt="image" src="http://blogs.technet.com/blogfiles/brianwren/WindowsLiveWriter/UsingWildcardswiththeWindowsServiceTempl_F7C9/image_thumb.png" width="673" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;3.&amp;nbsp; Open the XML file you just exported.&amp;nbsp; Use an XML editor if you have one.&amp;nbsp; Otherwise, you could use Notepad.&lt;/p&gt; &lt;p align="center"&gt;&lt;a href="http://blogs.technet.com/blogfiles/brianwren/WindowsLiveWriter/UsingWildcardswiththeWindowsServiceTempl_F7C9/image_4.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="342" alt="image" src="http://blogs.technet.com/blogfiles/brianwren/WindowsLiveWriter/UsingWildcardswiththeWindowsServiceTempl_F7C9/image_thumb_1.png" width="464" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;4.&amp;nbsp; You have to locate the discovery you just created which can be a little tricky since the names generated by the Operations Console are pretty long and ugly.&amp;nbsp; Probably the easiest method would be to search on the wildcard string you typed in.&amp;nbsp; &lt;/p&gt; &lt;p align="center"&gt;&lt;a href="http://blogs.technet.com/blogfiles/brianwren/WindowsLiveWriter/UsingWildcardswiththeWindowsServiceTempl_F7C9/image_6.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="151" alt="image" src="http://blogs.technet.com/blogfiles/brianwren/WindowsLiveWriter/UsingWildcardswiththeWindowsServiceTempl_F7C9/image_thumb_2.png" width="350" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p align="left"&gt;5.&amp;nbsp; The Discovery will look something like mine which I pasted below.&amp;nbsp; The long ID strings will be different in yours, but the rest should be pretty similar.&amp;nbsp; There's a lot going on here, but we're not going to have to worry about most of it.&amp;nbsp; I highlighted in blue the parts that we're going to need to change, and that shouldn't be too intimidating. &lt;/p&gt; &lt;p align="left"&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;font face="Consolas" size="2"&gt;&amp;lt;Discovery ID="ServiceStateProbePage_eaa08473602945a592b2a117b62c634f.DiscoveryRule" Enabled="true" Target="Windows!Microsoft.Windows.Computer" ConfirmDelivery="false" Remotable="true" Priority="Normal"&amp;gt;&lt;br&gt;&amp;nbsp; &amp;lt;Category&amp;gt;Discovery&amp;lt;/Category&amp;gt;&lt;br&gt;&amp;nbsp; &amp;lt;DiscoveryTypes&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;DiscoveryClass TypeID="ServiceStateProbePage_eaa08473602945a592b2a117b62c634f" /&amp;gt;&lt;br&gt;&amp;nbsp; &amp;lt;/DiscoveryTypes&amp;gt;&lt;br&gt;&amp;nbsp; &amp;lt;DataSource ID="DS" TypeID="&lt;font color="#0000ff"&gt;Windows!Microsoft.Windows.Win32ServiceInformationProviderWithClassSnapshotDataMapper&lt;/font&gt;"&amp;gt;&lt;br&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ComputerName&amp;gt;$Target/Property[Type="Windows!Microsoft.Windows.Computer"]/NetworkName$&amp;lt;/ComputerName&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ServiceName&amp;gt;vmi%&amp;lt;/ServiceName&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;font color="#000000"&gt;&amp;lt;Frequency&amp;gt;60&amp;lt;/Frequency&amp;gt;&lt;br&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ClassId&amp;gt;$MPElement[Name="ServiceStateProbePage_eaa08473602945a592b2a117b62c634f"]$&amp;lt;/ClassId&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;InstanceSettings&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Settings&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Setting&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Name&amp;gt;$MPElement[Name="Windows!Microsoft.Windows.Computer"]/PrincipalName$&amp;lt;/Name&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Value&amp;gt;$Target/Property[Type="Windows!Microsoft.Windows.Computer"]/PrincipalName$&amp;lt;/Value&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Setting&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Setting&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Name&amp;gt;$MPElement[Name="MicrosoftSystemCenterNTServiceLibrary!Microsoft.SystemCenter.NTService"]/ServiceName$&amp;lt;/Name&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Value&amp;gt;$Data/Property[@Name='Name']$&amp;lt;/Value&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Setting&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Setting&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Name&amp;gt;$MPElement[Name="MicrosoftSystemCenterNTServiceLibrary!Microsoft.SystemCenter.NTService"]/ServiceProcessName$&amp;lt;/Name&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Value&amp;gt;$Data/Property[@Name=&lt;font color="#0000ff"&gt;'BinaryPathName'&lt;/font&gt;]$&amp;lt;/Value&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Setting&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Setting&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Name&amp;gt;$MPElement[Name="MicrosoftSystemCenterNTServiceLibrary!Microsoft.SystemCenter.NTService"]/DisplayName$&amp;lt;/Name&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Value&amp;gt;$Data/Property[@Name='DisplayName']$&amp;lt;/Value&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Setting&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Setting&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Name&amp;gt;$MPElement[Name="MicrosoftSystemCenterNTServiceLibrary!Microsoft.SystemCenter.NTService"]/Description$&amp;lt;/Name&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Value&amp;gt;$Data/Property[@Name='Description']$&amp;lt;/Value&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Setting&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Setting&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Name&amp;gt;$MPElement[Name="System!System.Entity"]/DisplayName$&amp;lt;/Name&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Value&amp;gt;Hyper-V Services&amp;lt;/Value&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Setting&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Settings&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/InstanceSettings&amp;gt;&lt;br&gt;&amp;nbsp; &amp;lt;/DataSource&amp;gt;&lt;br&gt;&amp;lt;/Discovery&amp;gt;&lt;/font&gt; &lt;p align="left"&gt;&amp;nbsp;&lt;/p&gt; &lt;p align="left"&gt;6.&amp;nbsp; Modify the discovery to use the WMI discovery module.&amp;nbsp; I highlighted in red the modifications you want to make.&amp;nbsp; You could just copy and paste right from this pots into your management pack.&amp;nbsp; Obviously, in that query, you're going to use your wildcard string as opposed to the vmi% that I used.&amp;nbsp; All we're doing is changing out the module we're using as the data source for the discovery.&amp;nbsp; Then we're replacing the parameters that we were passing to the old module to the parameters expected by the new one.&amp;nbsp; &lt;/p&gt;&lt;font face="Consolas" size="2"&gt;&amp;lt;Discovery ID="ServiceStateProbePage_eaa08473602945a592b2a117b62c634f.DiscoveryRule" Enabled="true" Target="Windows!Microsoft.Windows.Computer" ConfirmDelivery="false" Remotable="true" Priority="Normal"&amp;gt;&lt;br&gt;&amp;nbsp; &amp;lt;Category&amp;gt;Discovery&amp;lt;/Category&amp;gt;&lt;br&gt;&amp;nbsp; &amp;lt;DiscoveryTypes&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;DiscoveryClass TypeID="ServiceStateProbePage_eaa08473602945a592b2a117b62c634f" /&amp;gt;&lt;br&gt;&amp;nbsp; &amp;lt;/DiscoveryTypes&amp;gt;&lt;br&gt;&amp;nbsp; &amp;lt;DataSource ID="DS" TypeID="&lt;font color="#ff0000"&gt;Windows!Microsoft.Windows.WmiProviderWithClassSnapshotDataMapper&lt;/font&gt;"&amp;gt;&lt;br&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color="#ff0000"&gt;&amp;lt;NameSpace&amp;gt;root\cimv2&amp;lt;/NameSpace&amp;gt;&lt;br&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color="#ff0000"&gt;&amp;lt;Query&amp;gt;select * from win32_service where name like 'vmi%'&amp;lt;/Query&amp;gt;&lt;br&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;font color="#000000"&gt;&amp;lt;Frequency&amp;gt;60&amp;lt;/Frequency&amp;gt;&lt;br&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ClassId&amp;gt;$MPElement[Name="ServiceStateProbePage_eaa08473602945a592b2a117b62c634f"]$&amp;lt;/ClassId&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;InstanceSettings&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Settings&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Setting&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Name&amp;gt;$MPElement[Name="Windows!Microsoft.Windows.Computer"]/PrincipalName$&amp;lt;/Name&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Value&amp;gt;$Target/Property[Type="Windows!Microsoft.Windows.Computer"]/PrincipalName$&amp;lt;/Value&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Setting&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Setting&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Name&amp;gt;$MPElement[Name="MicrosoftSystemCenterNTServiceLibrary!Microsoft.SystemCenter.NTService"]/ServiceName$&amp;lt;/Name&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Value&amp;gt;$Data/Property[@Name='Name']$&amp;lt;/Value&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Setting&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Setting&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Name&amp;gt;$MPElement[Name="MicrosoftSystemCenterNTServiceLibrary!Microsoft.SystemCenter.NTService"]/ServiceProcessName$&amp;lt;/Name&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Value&amp;gt;$Data/Property[@Name=&lt;font color="#ff0000"&gt;'PathName'&lt;/font&gt;]$&amp;lt;/Value&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Setting&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Setting&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Name&amp;gt;$MPElement[Name="MicrosoftSystemCenterNTServiceLibrary!Microsoft.SystemCenter.NTService"]/DisplayName$&amp;lt;/Name&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Value&amp;gt;$Data/Property[@Name='DisplayName']$&amp;lt;/Value&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Setting&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Setting&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Name&amp;gt;$MPElement[Name="MicrosoftSystemCenterNTServiceLibrary!Microsoft.SystemCenter.NTService"]/Description$&amp;lt;/Name&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Value&amp;gt;$Data/Property[@Name='Description']$&amp;lt;/Value&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Setting&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Setting&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Name&amp;gt;$MPElement[Name="System!System.Entity"]/DisplayName$&amp;lt;/Name&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Value&amp;gt;Hyper-V Services&amp;lt;/Value&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Setting&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Settings&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/InstanceSettings&amp;gt;&lt;br&gt;&amp;nbsp; &amp;lt;/DataSource&amp;gt;&lt;br&gt;&amp;lt;/Discovery&amp;gt;&lt;/font&gt; &lt;p align="left"&gt;7.&amp;nbsp; Import the modified management pack.&amp;nbsp; If you get an error on import, then you made a mistake in the modification.&amp;nbsp; Go back and export the management pack and try again.&lt;/p&gt; &lt;p align="left"&gt;8.&amp;nbsp; Go to Discovered Inventory and change the target type to your class.&amp;nbsp; Within a minute or two, you should start to see instances showing up.&lt;/p&gt; &lt;p align="center"&gt;&lt;a href="http://blogs.technet.com/blogfiles/brianwren/WindowsLiveWriter/UsingWildcardswiththeWindowsServiceTempl_F7C9/image_12.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="347" alt="image" src="http://blogs.technet.com/blogfiles/brianwren/WindowsLiveWriter/UsingWildcardswiththeWindowsServiceTempl_F7C9/image_thumb_5.png" width="610" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p align="left"&gt;&lt;/p&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=2977707" width="1" height="1"&gt;</description><category domain="http://blogs.technet.com/brianwren/archive/tags/OpsMgr/default.aspx">OpsMgr</category><category domain="http://blogs.technet.com/brianwren/archive/tags/Management+Packs/default.aspx">Management Packs</category></item><item><title>Scheduling Groups of Objects for Maintenance Mode</title><link>http://blogs.technet.com/brianwren/archive/2008/02/28/scheduling-groups-of-objects-for-maintenance-mode.aspx</link><pubDate>Thu, 28 Feb 2008 18:08:00 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:2940453</guid><dc:creator>Brian Wren</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.technet.com/brianwren/comments/2940453.aspx</comments><wfw:commentRss>http://blogs.technet.com/brianwren/commentrss.aspx?PostID=2940453</wfw:commentRss><description>&lt;P&gt;I was given a challenge recently to come up with a solution for an organization that wanted to suppress any alerts for certain computers and services during a particular time window every night.&amp;nbsp; The particular set of objects and the times in question had to be manageable by the administrators - preferably from the Operations Console.&lt;/P&gt;
&lt;P&gt;This is a great example for a few concepts, so this will be a pretty long post where I'll describe each step along the way.&amp;nbsp; If you just want the answer, scroll to the link at the end for the sample MP.&amp;nbsp; Otherwise, you should find some good information on the following concepts:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Launching a PowerShell script from a rule 
&lt;LI&gt;Composing a rule made up of a data source and write action 
&lt;LI&gt;Replacing explicit values in a rule with overrides 
&lt;LI&gt;Creating a simple custom class&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;First of all, the obvious answer to suppressing alerts is to get those objects into maintenance mode.&amp;nbsp; That way we not only aren't bothered by the alerts, but we can also remove this time window from any availability reporting.&amp;nbsp; The questions that we're faced with though are:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;How can we schedule maintenance mode on a regular basis? 
&lt;LI&gt;How can we set maintenance mode for a set of objects? 
&lt;LI&gt;How can we give control to the administrators through the Operations Console?&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;One answer for our challenge might be to write a Command Shell script to put an object in maintenance mode and then launch it from the Windows Scheduler.&amp;nbsp; That would handle question 1, but it would leave us hanging on questions 2 and 3. &lt;/P&gt;
&lt;P&gt;A very straightforward solution would be to create a group in OpsMgr.&amp;nbsp; Instead of setting maintenance mode for a single object, the script could put each member of the group in maintenance mode.&amp;nbsp; Administrators could easily populate the group with any objects that should be included in the maintenance window.&amp;nbsp; Assuming we had a script that could do that group enumeration, question 2 is covered.&amp;nbsp; In order to really address question 3, we would need to launch the script from an OpsMgr management pack instead of the Windows Scheduler and have the ability to overwrite critical parameters.&amp;nbsp; 
&lt;P&gt;So that leaves us with two challenges - setting maintenance mode for a group of objects and creating a rule to launch the script from a management pack.&amp;nbsp; Let's take them one at a time.&amp;nbsp; First the script..... 
&lt;H1&gt;Setting Maintenance Mode on a Group of Objects&lt;/H1&gt;
&lt;P&gt;We're going to need Command Shell in order to enumerate the group and set maintenance mode.&amp;nbsp; I'm assuming that we're going to end up creating a rule calling powershell.exe as described in my &lt;A href="http://blogs.technet.com/brianwren/archive/2008/02/20/running-powershell-scripts-from-a-management-pack.aspx" mce_href="http://blogs.technet.com/brianwren/archive/2008/02/20/running-powershell-scripts-from-a-management-pack.aspx"&gt;previous blog post&lt;/A&gt;, so we're going to need to need the script to include the code to load the Command Shell snap-in and setup the connection to the management server.&amp;nbsp; When we launch Command Shell from the menu, this is done automatically done for us. 
&lt;P&gt;The script should accept the group name as an argument and then enumerate all members of that group.&amp;nbsp; In specific OpsMgr terms, that means that we need to enumerate the objects that are target of a Containment relationship with the group's class.&amp;nbsp; 
&lt;P&gt;If we use the New-MaintenanceWindow CmdLet, then we would need to write a function to recurs through the group members and follow each group members down through its set of hosted and contained objects.&amp;nbsp; Rather than use that CmdLet, I'm going to use the &lt;A href="http://msdn2.microsoft.com/en-us/library/bb424489.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/bb424489.aspx"&gt;ScheduleMaintenanceMode&lt;/A&gt; method on the monitoring object class.&amp;nbsp; That method includes an argument called TraversalDepth.&amp;nbsp; A value of "OneLevel" means that only the object itself will be put into maintenance while a value of "Recursive" means that we will follow hosting and containment relationships all the way down the object tree setting maintenance mode on each object along the way. A middle ground would be nice where we could just address the second level of objects, which in our case would be the specific group members and not their contained objects, but that's a scenario we're going to have to address on our own. 
&lt;P&gt;I thus have two scenarios I want the script to support - setting maintenance mode for just the objects contained in the group and setting maintenance mode for those objects in addition to all of their contained objects.&amp;nbsp; The second scenario is actually easier since we just execute ScheduleMaintenanceMode against the group with TraversalDepth set the "Recursive".&amp;nbsp; For the first method, we're going to have the enumerate the group contents ourselves and then set maintenance mode for each one. 
&lt;P&gt;With all of that said, my script is below.&amp;nbsp; Notice that I'm accepting as arguments the name of the group (not to be confused with the Display Name), the number of hours for maintenance, whether to include hosted objects, and the description.&amp;nbsp; We'll make most of these overrideable on the rule so the administrator has control over them.&lt;PRE class=csharpcode&gt;$groupName = $args[0]
$HoursInMaintenance = $args[1]
$IncludeHostedObjects = $args[2]
$Description = $args[3]
$CommandShellPath = $args[4]

Add-PSSnapin &lt;SPAN class=str&gt;"Microsoft.EnterpriseManagement.OperationsManager.Client"&lt;/SPAN&gt;;
cd &lt;SPAN class=str&gt;"$CommandShellPath"&lt;/SPAN&gt;
.\Microsoft.EnterpriseManagement.OperationsManager.ClientShell.Startup.ps1

$api = new-object -comObject &lt;SPAN class=str&gt;"MOM.ScriptAPI"&lt;/SPAN&gt;
$api.LogScriptEvent(&lt;SPAN class=str&gt;"SetMaintenanceMode"&lt;/SPAN&gt;,100,4,&lt;SPAN class=str&gt;"Maintenance mode set for all members of group: $groupName"&lt;/SPAN&gt;)

$startTime = (Get-Date).ToUniversalTime()
$endTime = $startTime.AddHours($HoursInMaintenance)

$group = get-monitoringClass -name $groupName | get-monitoringObject

&lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; ($IncludeHostedObjects &lt;SPAN class=preproc&gt;-eq&lt;/SPAN&gt; $true) 
{
    $group.ScheduleMaintenanceMode($startTime,$endTime,&lt;SPAN class=str&gt;"PlannedOther"&lt;/SPAN&gt;,$Description,&lt;SPAN class=str&gt;"Recursive"&lt;/SPAN&gt;)
}
&lt;SPAN class=kwrd&gt;else&lt;/SPAN&gt;
{
    $classContain = get-relationshipClass -name &lt;SPAN class=str&gt;'System.Containment'&lt;/SPAN&gt;
    $relations = $group | get-relationshipObject | where {$_.SourceMonitoringObject &lt;SPAN class=preproc&gt;-eq&lt;/SPAN&gt; $group} 
    $groupMembers = $relations | &lt;SPAN class=kwrd&gt;foreach&lt;/SPAN&gt; {$_.TargetMonitoringObject}

    &lt;SPAN class=kwrd&gt;foreach&lt;/SPAN&gt; ($object &lt;SPAN class=kwrd&gt;in&lt;/SPAN&gt; $groupMembers)
    {
        $object.ScheduleMaintenanceMode($startTime,$endTime,&lt;SPAN class=str&gt;"PlannedOther"&lt;/SPAN&gt;,$Description,&lt;SPAN class=str&gt;"OneLevel"&lt;/SPAN&gt;)
    }
}&lt;/PRE&gt;&lt;PRE class=csharpcode&gt;&amp;nbsp;&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;.csharpcode {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	MARGIN: 0em
}
.csharpcode .rem {
	COLOR: #008000
}
.csharpcode .kwrd {
	COLOR: #0000ff
}
.csharpcode .str {
	COLOR: #006080
}
.csharpcode .op {
	COLOR: #0000c0
}
.csharpcode .preproc {
	COLOR: #cc6633
}
.csharpcode .asp {
	BACKGROUND-COLOR: #ffff00
}
.csharpcode .html {
	COLOR: #800000
}
.csharpcode .attr {
	COLOR: #ff0000
}
.csharpcode .alt {
	MARGIN: 0em; WIDTH: 100%; BACKGROUND-COLOR: #f4f4f4
}
.csharpcode .lnum {
	COLOR: #606060
}
&lt;/STYLE&gt;

&lt;STYLE type=text/css&gt;.csharpcode {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	MARGIN: 0em
}
.csharpcode .rem {
	COLOR: #008000
}
.csharpcode .kwrd {
	COLOR: #0000ff
}
.csharpcode .str {
	COLOR: #006080
}
.csharpcode .op {
	COLOR: #0000c0
}
.csharpcode .preproc {
	COLOR: #cc6633
}
.csharpcode .asp {
	BACKGROUND-COLOR: #ffff00
}
.csharpcode .html {
	COLOR: #800000
}
.csharpcode .attr {
	COLOR: #ff0000
}
.csharpcode .alt {
	MARGIN: 0em; WIDTH: 100%; BACKGROUND-COLOR: #f4f4f4
}
.csharpcode .lnum {
	COLOR: #606060
}
&lt;/STYLE&gt;

&lt;STYLE type=text/css&gt;.csharpcode {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	MARGIN: 0em
}
.csharpcode .rem {
	COLOR: #008000
}
.csharpcode .kwrd {
	COLOR: #0000ff
}
.csharpcode .str {
	COLOR: #006080
}
.csharpcode .op {
	COLOR: #0000c0
}
.csharpcode .preproc {
	COLOR: #cc6633
}
.csharpcode .asp {
	BACKGROUND-COLOR: #ffff00
}
.csharpcode .html {
	COLOR: #800000
}
.csharpcode .attr {
	COLOR: #ff0000
}
.csharpcode .alt {
	MARGIN: 0em; WIDTH: 100%; BACKGROUND-COLOR: #f4f4f4
}
.csharpcode .lnum {
	COLOR: #606060
}
&lt;/STYLE&gt;

&lt;H1&gt;Creating the Rule&lt;/H1&gt;
&lt;P&gt;The next question is how we're going to launch that script and give administrators control over the schedule.&amp;nbsp; We could do that from the Windows Scheduler, but it would be more straightforward for the administrator if we put it into an OpsMgr rule.&amp;nbsp; If we configure it correctly, we can allow our administrators to use overrides to control the schedule, length of maintenance mode, and whether to include contained objects.&amp;nbsp; &lt;/P&gt;
&lt;H2&gt;Data Source&lt;/H2&gt;
&lt;P&gt;The rule will need a data source and a write action.&amp;nbsp; Since we want to execute the script on a nightly schedule, System.Scheduler will be a perfect data source.&amp;nbsp; There is one little trick with that data source though.&amp;nbsp; It allows you to define multiple schedules that have a start and a stop time.&amp;nbsp; In the context we are going to use it though, the stop time is ignored.&amp;nbsp; It will have to be larger than the start time to prevent errors, but other than that it won't be used.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;You could just use System.Scheduler unchanged in which case you'll get the benefit of the dialog box for setting multiple schedules.&amp;nbsp; In that case, you would need to modify the rule itself to change the schedule though.&amp;nbsp; Since I want to control it through overrides I'm going to limit us to a single schedule, and I'm going to have to set the parameters myself.&amp;nbsp; The Start and End times are pretty obvious.&amp;nbsp; The DaysOfWeekMask is a little confusing.&amp;nbsp; This is the integer value of a bit mask with each day representing a single bit.&amp;nbsp; If you're familiar with bit masks you won't have a problem. If not, just determine the appropriate value by using the following values for each day of the week: Su-1, M-2, T-4, W-8, Th-16, F-32, Sa-64.&amp;nbsp; Just add up the values for the days you want the script to run.&amp;nbsp; If you want all days of the week, they'll add up to 127.&amp;nbsp; If you just want Sunday, the value is 1.&amp;nbsp; Just Tuesday and Thursday would be 20.&lt;/P&gt;
&lt;P&gt;With all of that said, here's a valid data source for running the script every day of the week at 10:00 pm.&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Consolas size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;DataSources&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;DataSource ID="Scheduler" TypeID="System!System.Scheduler"&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Scheduler&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;WeeklySchedule&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Windows&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Daily&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Start&amp;gt;22:00$&amp;lt;/Start&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;End&amp;gt;23:59&amp;lt;/End&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;DaysOfWeekMask&amp;gt;127&amp;lt;/DaysOfWeekMask&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Daily&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Windows&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/WeeklySchedule&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ExcludeDates/&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Scheduler&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/DataSource&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/DataSources&amp;gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To define overrides though, we have to create a new module type.&amp;nbsp; Rather than using this data source directly in the rule, I'll create a data source allowing the StartTime and DaysOfWeekMask to be overriden.&amp;nbsp; The rule will then use the new data source module.&amp;nbsp; Notice in the data source below that I've changed the changed the values for &amp;lt;Start&amp;gt; and &amp;lt;DaysOfTheWeeMask&amp;gt; to overrideable values that will be provided by the rule itself.&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Consolas size=2&gt;&amp;lt;DataSourceModuleType ID="bwren.Maintenance.DataSource.Scheduler" Accessibility="Public"&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Configuration&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xsd:element name="StartTime" type="xsd:string" xmlns:xsd="&lt;/FONT&gt;&lt;FONT face=Consolas size=2&gt;http://www.w3.org/2001/XMLSchema"/&lt;/FONT&gt;&lt;FONT face=Consolas size=2&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xsd:element name="DaysOfWeekMask" type="xsd:integer" xmlns:xsd="&lt;/FONT&gt;&lt;FONT face=Consolas size=2&gt;http://www.w3.org/2001/XMLSchema"/&lt;/FONT&gt;&lt;FONT face=Consolas size=2&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Configuration&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;OverrideableParameters&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;OverrideableParameter ID="StartTime" ParameterType="string" Selector="$Config/StartTime$"/&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;OverrideableParameter ID="DaysOfWeekMask" ParameterType="int" Selector="$Config/DaysOfWeekMask$"/&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/OverrideableParameters&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ModuleImplementation&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Composite&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;MemberModules&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;DataSource ID="DS" TypeID="System!System.Scheduler"&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Scheduler&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;WeeklySchedule&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Windows&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Daily&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Start&amp;gt;$Config/StartTime$&amp;lt;/Start&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;End&amp;gt;23:59&amp;lt;/End&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;DaysOfWeekMask&amp;gt;$Config/DaysOfWeekMask$&amp;lt;/DaysOfWeekMask&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Daily&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Windows&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/WeeklySchedule&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ExcludeDates/&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Scheduler&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/DataSource&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/MemberModules&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Composition&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Node ID="DS"/&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Composition&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Composite&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/ModuleImplementation&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;OutputType&amp;gt;System!System.TriggerData&amp;lt;/OutputType&amp;gt;&lt;BR&gt;&amp;lt;/DataSourceModuleType&amp;gt;&lt;/FONT&gt; 
&lt;H2&gt;Write Action&lt;/H2&gt;
&lt;P&gt;The write action is just a matter of launching our PowerShell script.&amp;nbsp; We'll again need a new module type to handle overrides.&amp;nbsp; That strategy has other benefits anyway, since we can put the complexity in the module type and keep the rule simple.&amp;nbsp; That will make it easy to create other rules for other groups.&lt;/P&gt;
&lt;P&gt;The module type using our script is shown below.&amp;nbsp; I won't bother explaining all the details since you can get that from the &lt;A href="http://blogs.technet.com/brianwren/archive/2008/02/20/running-powershell-scripts-from-a-management-pack.aspx" mce_href="http://blogs.technet.com/brianwren/archive/2008/02/20/running-powershell-scripts-from-a-management-pack.aspx"&gt;PowerShell post&lt;/A&gt;.&amp;nbsp; The formatting gets pretty screwed up here, so you might just want to have a look at it in the &lt;A href="http://brianwren.members.winisp.net/Management%20Packs/bwren.MaintenanceMode.xml" mce_href="http://brianwren.members.winisp.net/Management%20Packs/bwren.MaintenanceMode.xml"&gt;sample MP&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Consolas size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;WriteActionModuleType ID="bwren.Maintenance.WriteAction.SetMaintenance" Accessibility="Public"&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Configuration&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xsd:element name="GroupName" type="xsd:string" xmlns:xsd="&lt;/FONT&gt;&lt;FONT face=Consolas size=2&gt;http://www.w3.org/2001/XMLSchema"/&lt;/FONT&gt;&lt;FONT face=Consolas size=2&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xsd:element name="HoursInMaintenance" type="xsd:integer" xmlns:xsd="&lt;/FONT&gt;&lt;FONT face=Consolas size=2&gt;http://www.w3.org/2001/XMLSchema"/&lt;/FONT&gt;&lt;FONT face=Consolas size=2&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xsd:element name="IncludeHostedObjects" type="xsd:string" xmlns:xsd="&lt;/FONT&gt;&lt;FONT face=Consolas size=2&gt;http://www.w3.org/2001/XMLSchema"/&lt;/FONT&gt;&lt;FONT face=Consolas size=2&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xsd:element name="Description" type="xsd:string" xmlns:xsd="&lt;/FONT&gt;&lt;FONT face=Consolas size=2&gt;http://www.w3.org/2001/XMLSchema"/&lt;/FONT&gt;&lt;FONT face=Consolas size=2&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Configuration&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;OverrideableParameters&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;OverrideableParameter ID="HoursInMaintenance" Selector="$Config/HoursInMaintenance$" ParameterType="int"/&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;OverrideableParameter ID="IncludeHostedObjects" Selector="$Config/IncludeHostedObjects$" ParameterType="string"/&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/OverrideableParameters&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ModuleImplementation Isolation="Any"&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Composite&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;MemberModules&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;WriteAction ID="WA1" TypeID="System!System.CommandExecuter"&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ApplicationName&amp;gt;%windir%\system32\windowspowershell\v1.0\powershell.exe&amp;lt;/ApplicationName&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;WorkingDirectory/&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;CommandLine&amp;gt;-Command "&amp;amp;amp; {.\SetMaintenance.ps1 $Config/GroupName$ $Config/HoursInMaintenance$ $Config/IncludeHostedObjects$ '$Config/Description$'}"&amp;lt;/CommandLine&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;SecureInput/&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;TimeoutSeconds&amp;gt;30&amp;lt;/TimeoutSeconds&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;RequireOutput&amp;gt;true&amp;lt;/RequireOutput&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Files&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;File&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Name&amp;gt;SetMaintenance.ps1&amp;lt;/Name&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Contents&amp;gt;&amp;lt;![CDATA[&lt;BR&gt;$groupName = $args[0]&lt;BR&gt;$HoursInMaintenance = $args[1]&lt;BR&gt;$IncludeHostedObjects = $args[2]&lt;BR&gt;$Description = $args[3] &lt;/FONT&gt;
&lt;P&gt;&lt;FONT face=Consolas size=2&gt;Add-PSSnapin "Microsoft.EnterpriseManagement.OperationsManager.Client";&lt;BR&gt;cd C:\"Program Files"\"System Center Operations Manager 2007"&lt;BR&gt;.\Microsoft.EnterpriseManagement.OperationsManager.ClientShell.Startup.ps1 &lt;/FONT&gt;
&lt;P&gt;&lt;FONT face=Consolas size=2&gt;$startTime = (Get-Date).ToUniversalTime()&lt;BR&gt;$endTime = $startTime.AddHours($HoursInMaintenance) &lt;/FONT&gt;
&lt;P&gt;&lt;FONT face=Consolas size=2&gt;$group = get-monitoringClass -name $groupName | get-monitoringObject &lt;/FONT&gt;
&lt;P&gt;&lt;FONT face=Consolas size=2&gt;if ($IncludeHostedObjects -eq $true) &lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $group.ScheduleMaintenanceMode($startTime,$endTime,"PlannedOther",$Description,"Recursive")&lt;BR&gt;}&lt;BR&gt;else&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $classContain = get-relationshipClass -name 'System.Containment'&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $relations = $group | get-relationshipObject | where {$_.SourceMonitoringObject -eq $group} &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $groupMembers = $relations | foreach {$_.TargetMonitoringObject} &lt;/FONT&gt;
&lt;P&gt;&lt;FONT face=Consolas size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; foreach ($object in $groupMembers)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $object.ScheduleMaintenanceMode($startTime,$endTime,"PlannedOther",$Description,"OneLevel")&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;}&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ]]&amp;gt;&amp;lt;/Contents&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Unicode&amp;gt;true&amp;lt;/Unicode&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/File&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Files&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/WriteAction&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/MemberModules&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Composition&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Node ID="WA1"/&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Composition&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Composite&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/ModuleImplementation&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;OutputType&amp;gt;System!System.CommandOutput&amp;lt;/OutputType&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;InputType&amp;gt;System!System.BaseData&amp;lt;/InputType&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/WriteActionModuleType&amp;gt;&lt;/FONT&gt; 
&lt;P&gt;&lt;FONT face=Consolas size=2&gt;&lt;/FONT&gt;
&lt;P&gt;&lt;FONT face=Consolas size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;H1&gt;Setting the Rule Target&lt;/H1&gt;
&lt;P&gt;With those modules created, we need a rule that includes each data source and specifies the required arguments.&amp;nbsp; The biggest question is what to use as its target.&amp;nbsp; Technically, we can target anything that will end up deploying to an agent with PowerShell and Command Shell installed.&amp;nbsp; We only want a single agent to get it though.&amp;nbsp; We also want to make sure that our target is going to be accessible to the server admins.&amp;nbsp; The root management server typically has Command Shell installed, and this is a perfect candidate for this task.&amp;nbsp; Chances are pretty good though that we don't want to give permission to our administrators to author rules against our RMS.&lt;/P&gt;
&lt;P&gt;I had thought of targeting the group itself since, as described in another &lt;A href="http://blogs.technet.com/brianwren/archive/2007/08/22/targeting-rules-and-monitors.aspx" mce_href="http://blogs.technet.com/brianwren/archive/2007/08/22/targeting-rules-and-monitors.aspx"&gt;previous post&lt;/A&gt; the root management server "hosts" groups, so that's where the rule would get deployed.&amp;nbsp; I had some issues with this working reliably though, and I also thought it might get a bit confusing.&lt;/P&gt;
&lt;P&gt;The solution I went with was to create a new class based on ComputerRole called CommandShellProxy. This can serve as the target for any rules I want to create that launch a Command Shell script.&amp;nbsp; I can give permission to different people to override rules targeted at it without giving them access to the rules and monitors directly targeting the RMS.&amp;nbsp; As an added benefit, I stored the path to the PowerShell executable and the Command Shell snap-in so I don't have to hardcode those into the rule.&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Consolas size=2&gt;&amp;lt;ClassType ID="bwren.MaintenanceMode.CommandShellProxy" Accessibility="Public" Abstract="false" Base="Windows!Microsoft.Windows.ComputerRole" Hosted="true" Singleton="false"&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Property ID="PowerShellPath" Type="string"/&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Property ID="CommandShellPath" Type="string"/&amp;gt;&lt;BR&gt;&amp;lt;/ClassType&amp;gt;&lt;/FONT&gt; 
&lt;P&gt;I did a simple registry discovery for my new class and targeted it at the Root Management Server class.&amp;nbsp; The only criteria I'm using is determining whether Command Shell is installed.&amp;nbsp; If you want to use something other than the RMS as your Command Shell proxy, all you would have to do is change that discovery.&lt;/P&gt;
&lt;P&gt;I didn't bother pasting in the discovery XML since I've already cluttered up this post with enough code.&amp;nbsp; You can have a look at it in the sample MP though. &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;H1&gt;End Result&lt;/H1&gt;
&lt;P&gt;Go to the bottom of this post for a link to the sample MP.&amp;nbsp; You can go through the following steps to get it up and running:&lt;/P&gt;
&lt;P&gt;1.&amp;nbsp; Load the management pack &lt;/P&gt;
&lt;P align=center&gt;&lt;A href="http://blogs.technet.com/blogfiles/brianwren/WindowsLiveWriter/SchedulingGroupsofObjectsforMaintenanceM_702C/image_12.png" mce_href="http://blogs.technet.com/blogfiles/brianwren/WindowsLiveWriter/SchedulingGroupsofObjectsforMaintenanceM_702C/image_12.png"&gt;&lt;IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=139 alt=image src="http://blogs.technet.com/blogfiles/brianwren/WindowsLiveWriter/SchedulingGroupsofObjectsforMaintenanceM_702C/image_thumb.png" width=475 border=0 mce_src="http://blogs.technet.com/blogfiles/brianwren/WindowsLiveWriter/SchedulingGroupsofObjectsforMaintenanceM_702C/image_thumb.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P align=center mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2.&amp;nbsp; Add an object or two to the group &lt;EM&gt;Maintenance Mode Group 1&lt;/EM&gt;. &lt;/P&gt;
&lt;P align=center&gt;&lt;A href="http://blogs.technet.com/blogfiles/brianwren/WindowsLiveWriter/SchedulingGroupsofObjectsforMaintenanceM_702C/image9.png" mce_href="http://blogs.technet.com/blogfiles/brianwren/WindowsLiveWriter/SchedulingGroupsofObjectsforMaintenanceM_702C/image9.png"&gt;&lt;IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=432 alt=image src="http://blogs.technet.com/blogfiles/brianwren/WindowsLiveWriter/SchedulingGroupsofObjectsforMaintenanceM_702C/image9_thumb.png" width=451 border=0 mce_src="http://blogs.technet.com/blogfiles/brianwren/WindowsLiveWriter/SchedulingGroupsofObjectsforMaintenanceM_702C/image9_thumb.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3.&amp;nbsp; Make sure that you are discovering the Command Shell Proxy by selecting Discovered Inventory.&amp;nbsp; Then click on Change Target and select Command Shell Proxy from the list.&lt;/P&gt;
&lt;P align=center&gt;&amp;nbsp;&lt;A href="http://blogs.technet.com/blogfiles/brianwren/WindowsLiveWriter/SchedulingGroupsofObjectsforMaintenanceM_702C/image_14.png" mce_href="http://blogs.technet.com/blogfiles/brianwren/WindowsLiveWriter/SchedulingGroupsofObjectsforMaintenanceM_702C/image_14.png"&gt;&lt;IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=139 alt=image src="http://blogs.technet.com/blogfiles/brianwren/WindowsLiveWriter/SchedulingGroupsofObjectsforMaintenanceM_702C/image_thumb_5.png" width=814 border=0 mce_src="http://blogs.technet.com/blogfiles/brianwren/WindowsLiveWriter/SchedulingGroupsofObjectsforMaintenanceM_702C/image_thumb_5.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;4.&amp;nbsp; Go to the Authoring tab and look at rules for the target &lt;EM&gt;Command Shell Proxy&lt;/EM&gt;. &lt;/P&gt;
&lt;P align=center&gt;&lt;A href="http://blogs.technet.com/blogfiles/brianwren/WindowsLiveWriter/SchedulingGroupsofObjectsforMaintenanceM_702C/image_16.png" mce_href="http://blogs.technet.com/blogfiles/brianwren/WindowsLiveWriter/SchedulingGroupsofObjectsforMaintenanceM_702C/image_16.png"&gt;&lt;IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=124 alt=image src="http://blogs.technet.com/blogfiles/brianwren/WindowsLiveWriter/SchedulingGroupsofObjectsforMaintenanceM_702C/image_thumb_6.png" width=617 border=0 mce_src="http://blogs.technet.com/blogfiles/brianwren/WindowsLiveWriter/SchedulingGroupsofObjectsforMaintenanceM_702C/image_thumb_6.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P align=center mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;4.&amp;nbsp; Create an override on the rule &lt;EM&gt;Set maintenance mode - group 1&lt;/EM&gt;, and set appropriate values for StartTime, HoursInMaintenance, IncludeHostedObjects, and Description.&amp;nbsp; The allowable values for IncludeHostedObjects are $true and $false (those are the PowerShell variables for True and False.&amp;nbsp; You could do a little script work to allow a boolean in the override and then convert appropriately if you really want).&lt;/P&gt;
&lt;P align=center&gt;&lt;A href="http://blogs.technet.com/blogfiles/brianwren/WindowsLiveWriter/SchedulingGroupsofObjectsforMaintenanceM_702C/image_18.png" mce_href="http://blogs.technet.com/blogfiles/brianwren/WindowsLiveWriter/SchedulingGroupsofObjectsforMaintenanceM_702C/image_18.png"&gt;&lt;IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=239 alt=image src="http://blogs.technet.com/blogfiles/brianwren/WindowsLiveWriter/SchedulingGroupsofObjectsforMaintenanceM_702C/image_thumb_7.png" width=604 border=0 mce_src="http://blogs.technet.com/blogfiles/brianwren/WindowsLiveWriter/SchedulingGroupsofObjectsforMaintenanceM_702C/image_thumb_7.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I know this is a long and detailed post, but it seemed like a good opportunity to illustrate a few points.&amp;nbsp; Hope it's helpful.&lt;/P&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=2940453" width="1" height="1"&gt;</description><enclosure url="http://blogs.technet.com/brianwren/attachment/2940453.ashx" length="27122" type="application/octet-stream" /><category domain="http://blogs.technet.com/brianwren/archive/tags/OpsMgr/default.aspx">OpsMgr</category><category domain="http://blogs.technet.com/brianwren/archive/tags/Command+Shell/default.aspx">Command Shell</category><category domain="http://blogs.technet.com/brianwren/archive/tags/Management+Packs/default.aspx">Management Packs</category></item><item><title>Management Pack Authoring Guide (Told you)</title><link>http://blogs.technet.com/brianwren/archive/2008/02/24/management-pack-authoring-guide-told-you.aspx</link><pubDate>Mon, 25 Feb 2008 04:33:20 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:2929474</guid><dc:creator>Brian Wren</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.technet.com/brianwren/comments/2929474.aspx</comments><wfw:commentRss>http://blogs.technet.com/brianwren/commentrss.aspx?PostID=2929474</wfw:commentRss><description>&lt;p&gt;Just a few days ago, I mentioned that the new Operations Manager 2007 Management Pack Authoring Guide was going to be released "very soon".&amp;nbsp; Sure enough, it's been posted at &lt;a href="http://download.microsoft.com/download/7/4/d/74deff5e-449f-4a6b-91dd-ffbc117869a2/OM2007_AuthGuide.doc"&gt;http://download.microsoft.com/download/7/4/d/74deff5e-449f-4a6b-91dd-ffbc117869a2/OM2007_AuthGuide.doc&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;This is the guide that all of us in the authoring community have been waiting on for some time.&amp;nbsp; At 238 pages, it provides a ton of information on management pack concepts, structuring work flows, creating custom modules, etc.&amp;nbsp; It also includes a complete reference on the XML schema of a management pack.&lt;/p&gt; &lt;p&gt;This is a first version of the authoring guide, and it will be getting updated with additional information.&amp;nbsp; One topic with minimal information in this version is the details of writing a script in a management pack.&amp;nbsp; I'm going to get out a blog entry out later this week on this topic to get some of the basics out there until the guide itself provides complete details on it.&lt;/p&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=2929474" width="1" height="1"&gt;</description><category domain="http://blogs.technet.com/brianwren/archive/tags/OpsMgr/default.aspx">OpsMgr</category><category domain="http://blogs.technet.com/brianwren/archive/tags/Management+Packs/default.aspx">Management Packs</category></item><item><title>Running PowerShell Scripts from a Management Pack - Part 1</title><link>http://blogs.technet.com/brianwren/archive/2008/02/20/running-powershell-scripts-from-a-management-pack.aspx</link><pubDate>Thu, 21 Feb 2008 02:04:11 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:2916870</guid><dc:creator>Brian Wren</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.technet.com/brianwren/comments/2916870.aspx</comments><wfw:commentRss>http://blogs.technet.com/brianwren/commentrss.aspx?PostID=2916870</wfw:commentRss><description>&lt;p&gt;Considering all my work with OpsMgr management packs and my infatuation with PowerShell, it's surprising that I've never put the two together in a public forum.&amp;nbsp; I keep meaning to, just don't ever seem to get there.&amp;nbsp; I finally committed myself to this blog post while sitting at my local It's a Grind (that's a coffee house to all you Seattle Starbucks fans.&amp;nbsp; &lt;a href="http://www.itsagrind.com/"&gt;It's a Grind&lt;/a&gt; was born in Long Beach, and I am fanatically loyal to my home town).&lt;/p&gt; &lt;p&gt;So here's the basic question - can I use a PowerShell script in an OpsMgr management pack?&amp;nbsp; In other words, can I execute a PowerShell script from a rule, monitor, diagnostic, recovery, or task?&amp;nbsp; The answer is absolutely you can, but there are some considerations to keep in mind.&amp;nbsp; First let's cover those considerations, then we'll get to concepts and code.&amp;nbsp; If you just want the modules to copy and paste into your MP, go ahead and jump to the end.&lt;/p&gt; &lt;p&gt;The biggest issue is that most of the servers in your environment don't have PowerShell installed.&amp;nbsp; Rules and monitors sent to an agent are executed locally on the agent computer, and any executables must be installed prior to the agent attempting to use them.&amp;nbsp; In the case of VBScript and JScript, we rely on cscript.exe being present, but that's a safe bet since it is automatically installed on all Windows machines.&amp;nbsp; Powershell is obviously not installed by default, and even in Windows Server 2008 it's an optional feature.&amp;nbsp; If you want to use a PowerShell script for a console task, then you're going to need to make sure that it is installed on the client workstation the task is being executed from.&amp;nbsp; This is less of a concern though since, while PowerShell and Command Shell are not required for the OpsMgr User Interfaces, they are pretty strongly suggested. &lt;/p&gt; &lt;p&gt;There can also be some significant overhead from launching PowerShell.&amp;nbsp; Go ahead and launch a PowerShell window and then have a look at Task Manager.&amp;nbsp; Powershell.exe will probably be consuming something like 30 MB of memory which is about 5x the typical cscript.exe instance in my personal testing.&amp;nbsp; This is not surprising considering all the rich functionality that PowerShell provides.&amp;nbsp; My only point is to try to stay away from scenarios where you need to launch a PowerShell script every couple of minutes.&amp;nbsp; I've heard the OpsMgr product team is working on some strategies to reduce this overhead, but until then you want to use PowerShell scripts where they don't have to be launched too frequently.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Concepts&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;The basic idea of running a PowerShell script is to use of the Command Executer modules to launch powershell.exe with your script.&amp;nbsp; This is actually the method that quite a few of the scripts in existing management packs use - calling cscript.exe with these modules.&amp;nbsp; The Command Executer modules will launch the executable of your choice, allow you to specify command line arguments, and allow you to specify the name and contents of one or more text files (which will obviously be your script).&amp;nbsp; These text files are created on the agent prior to command execution, so you can be guaranteed they will be in place when your specified command is launched.&lt;/p&gt; &lt;p&gt;Have a look at Microsoft.Windows.ScriptProbeAction in Microsoft.Windows.Library for example.&amp;nbsp; That module uses System.CommandExecuterProbe from System.Library.&amp;nbsp; It specifies cscript.exe as the command to execute, provides the appropriate command line arguments such as /nologo and the name of the script, and then passes in the body of the script as a file.&amp;nbsp; In order to execute Powershell, we really just need to figure out the command line required to launch PowerShell, execute a script, and then exit.&lt;/p&gt; &lt;h2&gt;&lt;/h2&gt; &lt;p&gt;&lt;strong&gt;PowerShell Command Line&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;If you run powershell.exe /?, you get the command line arguments for PowerShell.&amp;nbsp; To launch a command and exit, you use the -command argument, the&amp;nbsp; invoke operator (&amp;amp;), and a command to execute.&amp;nbsp; The example syntax given by that help is as follows:&lt;/p&gt; &lt;p align="center"&gt;powershell -command "&amp;amp; {get-eventlog -logname security}"&lt;/p&gt; &lt;p align="left"&gt;We're going to need that basic syntax but put it in a format that the management pack can understand.&amp;nbsp; It won't handle that ampersand, and we're go to have to have to specify a path for the script.&amp;nbsp; PowerShell demands a complete path to a script even if it's in the current directory.&amp;nbsp; The Command Executer will drop the script to a temporary directory and then use that directory as its default when it executes the script, so we can assume the script will be located in the current directory.&amp;nbsp; Assuming that we are going to use a parameter called ScriptName for the name of the script, then the command line in the management pack would look like the following:&lt;/p&gt; &lt;p align="center"&gt;-command "&amp;amp;amp; {.\$Config/ScriptName$}"&lt;/p&gt; &lt;p align="left"&gt;If you're completely baffled by that syntax, here's a quick explanation.&amp;nbsp; We replace &amp;amp; with &amp;amp;amp; because OpsMgr interprets the &amp;amp; as a special character.&amp;nbsp; We get away with that character in the script itself if we enclose the script in CDATA tags, but we can't use CDATA tags on our command line.&amp;nbsp; $Config/ScriptName$ is a context variable.&amp;nbsp; OpsMgr will replace the variable inside the dollar signs with its actual value at run time.&amp;nbsp; Config refers to the parameters of the module, and ScriptName is the name of the parameter.&amp;nbsp; Finally, the .\ just refers to the current directory.&amp;nbsp; So, if we used MyScript.ps1 for the script name, we would end up running the following command:&lt;/p&gt; &lt;p align="center"&gt;powershell -command "&amp;amp; {.\MyScript.ps1}"&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Implementing the Modules&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Rather than write a specific rule that uses the Command Executer modules and includes the specific PowerShell complexity, it is way more valuable to create a couple of base modules that can be leveraged by rules, monitors, and tasks.&amp;nbsp; A Data Source module that runs a PowerShell script on a timed basis and returns a property bag could be used for a rule, monitor, or diagnostic.&amp;nbsp; Another Data Source module returning discovery&amp;nbsp;&amp;nbsp; A Write Action module that just runs a PowerShell script on demand to perform some defined action would support a task or recovery.&lt;/p&gt; &lt;p&gt;I'll provide the data source below.&amp;nbsp; Given this it should be pretty straightforward to create a write action (hint - use System!System.CommandExecuter).&amp;nbsp; You could also create a discovery module based on System!System.CommandExecuterDiscoveryDataSource.&lt;/p&gt; &lt;p&gt;&amp;lt;DataSourceModuleType ID="PowerShell.Library.PSScriptPropertyBagSource" Accessibility="Public"&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Configuration&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="IntervalSeconds" type="xsd:integer"/&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="TimeoutSeconds" type="xsd:integer"/&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="ScriptName" type="xsd:string"/&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="Arguments" type="xsd:string"/&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="ScriptBody" type="xsd:string"/&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Configuration&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ModuleImplementation&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Composite&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;MemberModules&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;DataSource ID="DS" TypeID="System!System.CommandExecuterPropertyBagSource"&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;IntervalSeconds&amp;gt;60&amp;lt;/IntervalSeconds&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ApplicationName&amp;gt;%windir%\system32\windowspowershell\v1.0\powershell.exe&amp;lt;/ApplicationName&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;WorkingDirectory/&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;CommandLine&amp;gt;-Command "&amp;amp;amp; '$Config/ScriptName$"&amp;lt;/CommandLine&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;SecureInput/&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;TimeoutSeconds&amp;gt;30&amp;lt;/TimeoutSeconds&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;RequireOutput&amp;gt;false&amp;lt;/RequireOutput&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Files&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;File&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Name&amp;gt;$Config/ScriptName$&amp;lt;/Name&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Contents&amp;gt;$Config/ScriptBody$&amp;lt;/Contents&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Unicode&amp;gt;true&amp;lt;/Unicode&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/File&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Files&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/DataSource&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/MemberModules&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Composition&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Node ID="DS"/&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Composition&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Composite&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/ModuleImplementation&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;OutputType&amp;gt;System!System.PropertyBagData&amp;lt;/OutputType&amp;gt;&lt;br&gt;&amp;lt;/DataSourceModuleType&amp;gt; &lt;p&gt;&lt;strong&gt;Writing the Script&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;For the write action, there's really nothing special about the script.&amp;nbsp; Any working PowerShell script will be fine.&amp;nbsp; If you need to return a property bag or discovery data from a data source though, you're going to need to use MOM.ScriptAPI just like in VBScript.&amp;nbsp; PowerShell works fine with COM objects, so this is not a problem at all.&amp;nbsp; The following line will create an object variable, and using it is pretty similar to how you did it in VBScript.&lt;/p&gt; &lt;p align="center"&gt;$api = new-object -comObject "MOM.ScriptAPI"&lt;/p&gt; &lt;p&gt;For example, below is a PowerShell script to output the name and size of a specified file as a property bag.&amp;nbsp; This could be called from a rule or monitor that uses a condition detection to map the property bag information to performance data. While this is coded in PowerShell, the basic process is identical to a script &lt;/p&gt; &lt;p&gt;&lt;font face="Courier New"&gt;$file = Get-Item $args[0]&lt;br&gt;$api = New-Object -comObject "MOM.ScriptAPI"&lt;br&gt;$bag = $api.CreatePropertyBag()&lt;br&gt;$bag.AddValue($file.Name,$file.Length)&lt;br&gt;$api.Return($bag)&lt;/font&gt; &lt;p&gt;&lt;strong&gt;More Later&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;This should be enough information to get people off and running.&amp;nbsp; I'd like to provide some more samples and thought of actually writing a library MP with a complete set of PowerShell modules.&amp;nbsp; No hard commitment on that, but I'll do my best in coming weeks.&lt;/p&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=2916870" width="1" height="1"&gt;</description><category domain="http://blogs.technet.com/brianwren/archive/tags/Scripting/default.aspx">Scripting</category><category domain="http://blogs.technet.com/brianwren/archive/tags/OpsMgr/default.aspx">OpsMgr</category><category domain="http://blogs.technet.com/brianwren/archive/tags/PowerShell/default.aspx">PowerShell</category><category domain="http://blogs.technet.com/brianwren/archive/tags/Management+Packs/default.aspx">Management Packs</category></item><item><title>Dynamically populating component groups in Operations Manager 2007 Distributed Applications</title><link>http://blogs.technet.com/brianwren/archive/2008/01/26/dynamically-populating-component-groups-in-distributed-applications.aspx</link><pubDate>Sun, 27 Jan 2008 07:29:00 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:2785327</guid><dc:creator>Brian Wren</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.technet.com/brianwren/comments/2785327.aspx</comments><wfw:commentRss>http://blogs.technet.com/brianwren/commentrss.aspx?PostID=2785327</wfw:commentRss><description>&lt;P&gt;This is one I've been asked about several times and am finally getting around to blogging the answer.&amp;nbsp; The Distributed Application Designer in Operations Manager 2007 makes creating and modifying distributed applications quite easy.&amp;nbsp; You can create a component group with a few clicks and then drag in managed objects that are related to the application.&amp;nbsp; What cannot be done with the designer though is create a component group that is automatically populated through a rule like you can do with Operations Manager groups.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;To illustrate this point, note the distributed application below that represents a simple application with a farm of web servers.&amp;nbsp; I created this using the Line of Business Web Application template.&amp;nbsp; The component group Monster Island Web Application Web Sites includes all web sites serving the application.&amp;nbsp; These were manually added to the distributed application by dragging the appropriate instances into the group.&amp;nbsp; This is the way that distributed applications are typically built.&lt;/P&gt;
&lt;P align=center&gt;&lt;A href="http://blogs.technet.com/blogfiles/brianwren/WindowsLiveWriter/DynamicallypopulatingcomponentgroupsinDi_6E48/image_2.png" mce_href="http://blogs.technet.com/blogfiles/brianwren/WindowsLiveWriter/DynamicallypopulatingcomponentgroupsinDi_6E48/image_2.png"&gt;&lt;IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=252 alt=image src="http://blogs.technet.com/blogfiles/brianwren/WindowsLiveWriter/DynamicallypopulatingcomponentgroupsinDi_6E48/image_thumb.png" width=300 border=0 mce_src="http://blogs.technet.com/blogfiles/brianwren/WindowsLiveWriter/DynamicallypopulatingcomponentgroupsinDi_6E48/image_thumb.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;In this example, any web site called Gargantua should be added to the Web Sites component group.&amp;nbsp; If a new web server is installed, then we would need to open the Distributed Application Designer and drag this new web site instance to the group.&amp;nbsp; If we had a means to create a discovery for the component group though, then it would automatically be added once the new web site instance were discovered by Operations Manager.&lt;/P&gt;
&lt;P&gt;Creating such a discovery is entirely possible and actually not all that difficult.&amp;nbsp; You won't be able to use the Operations Console though, and you will need to be familiar with either the Authoring Console or working with management packs in XML.&amp;nbsp; The basic strategy is to modify the GroupPopulator module for the component group to use a membership rule instead of using specific managed objects.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;I'm going to use the Authoring Console to have a look at this discovery.&amp;nbsp; Since I created it in the Operations Console, the name of it is going to be pretty ugly.&amp;nbsp; If you have a large management pack, it might take a little searching to find the right item.&amp;nbsp; The name will start with SC_, and it will have Microsoft.SystemCenter.GroupPopulator as a data source.&amp;nbsp; Here's a look at the details of mine.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P align=center&gt;&lt;A href="http://blogs.technet.com/blogfiles/brianwren/WindowsLiveWriter/DynamicallypopulatingcomponentgroupsinDi_6E48/image_4.png" mce_href="http://blogs.technet.com/blogfiles/brianwren/WindowsLiveWriter/DynamicallypopulatingcomponentgroupsinDi_6E48/image_4.png"&gt;&lt;IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=399 alt=image src="http://blogs.technet.com/blogfiles/brianwren/WindowsLiveWriter/DynamicallypopulatingcomponentgroupsinDi_6E48/image_thumb_1.png" width=404 border=0 mce_src="http://blogs.technet.com/blogfiles/brianwren/WindowsLiveWriter/DynamicallypopulatingcomponentgroupsinDi_6E48/image_thumb_1.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note the IncludeList section which has two MonitoringObjectID entries.&amp;nbsp; Those are the GUIDs of the two web sites that I added to the component group.&amp;nbsp; If I was to drag a third site into the group, we would see that entry.&lt;/P&gt;
&lt;P&gt;The goal is to replace that Membership Rule with one that uses include logic instead of specific instances.&amp;nbsp; That way whenever the discovery executes, it will dynamically find appropriate objects to add to the component group.&amp;nbsp; It turns out that the same GroupPopulator that this discovery is based on is used for regular groups in Operations manager.&amp;nbsp; Groups have a nice wizard in the Operations Console for creating a population rule.&amp;nbsp; An easy strategy is to create a temporary group using the logic we want, and then copying and paste that logic into the component group discovery.&lt;/P&gt;
&lt;P&gt;For this example, I'll create a rule that includes all web sites with the name Gargantua.&amp;nbsp; I created a dummy group called Temp Group in the Operations Console and used the wizard to create the logic shown in the figure below. &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P align=center&gt;&amp;nbsp;&lt;A href="http://blogs.technet.com/blogfiles/brianwren/WindowsLiveWriter/DynamicallypopulatingcomponentgroupsinDi_1200B/image_4.png" mce_href="http://blogs.technet.com/blogfiles/brianwren/WindowsLiveWriter/DynamicallypopulatingcomponentgroupsinDi_1200B/image_4.png"&gt;&lt;IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=421 alt=image src="http://blogs.technet.com/blogfiles/brianwren/WindowsLiveWriter/DynamicallypopulatingcomponentgroupsinDi_1200B/image_thumb_1.png" width=504 border=0 mce_src="http://blogs.technet.com/blogfiles/brianwren/WindowsLiveWriter/DynamicallypopulatingcomponentgroupsinDi_1200B/image_thumb_1.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Viewing the discovery for that group in the Authoring Console, we see an Expression instead of an Include List.&amp;nbsp; That's exactly what we want to go into our component group discovery.&lt;/P&gt;
&lt;P align=center&gt;&lt;A href="http://blogs.technet.com/blogfiles/brianwren/WindowsLiveWriter/DynamicallypopulatingcomponentgroupsinDi_6E48/image_6.png" mce_href="http://blogs.technet.com/blogfiles/brianwren/WindowsLiveWriter/DynamicallypopulatingcomponentgroupsinDi_6E48/image_6.png"&gt;&lt;IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=399 alt=image src="http://blogs.technet.com/blogfiles/brianwren/WindowsLiveWriter/DynamicallypopulatingcomponentgroupsinDi_6E48/image_thumb_2.png" width=404 border=0 mce_src="http://blogs.technet.com/blogfiles/brianwren/WindowsLiveWriter/DynamicallypopulatingcomponentgroupsinDi_6E48/image_thumb_2.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In order to pull&amp;nbsp; this off, you're going to need to edit some XML.&amp;nbsp; First, export the management pack into an XML file where you can open it with an XML editor or the Authoring Console.&amp;nbsp; The Authoring Console will launch your editor of choice if you click the Edit button, or you could just open the management pack itself if you're more comfortable with that.&amp;nbsp; If you don't have an XML editor, then Notepad should work without much trouble.&amp;nbsp; Launching it from the Authoring Console will load just the XML for the discovery in question, so it shouldn't be too daunting.&lt;/P&gt;
&lt;P&gt;The XML for the group discovery is as follows:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;lt;RuleId&amp;gt;$MPElement$&amp;lt;/RuleId&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;GroupInstanceId&amp;gt;$MPElement[Name="UINameSpace236d6bdf988b4598979fb687226e0729.Group"]$&amp;lt;/GroupInstanceId&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;MembershipRules&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;MembershipRule&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;MonitoringClass&amp;gt;$MPElement[Name="System!System.WebSite"]$&amp;lt;/MonitoringClass&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;RelationshipClass&amp;gt;$MPElement[Name="MicrosoftSystemCenterInstanceGroupLibrary6062460!Microsoft.SystemCenter.InstanceGroupContainsEntities"]$&amp;lt;/RelationshipClass&amp;gt;&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Expression&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;SimpleExpression&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ValueExpression&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Property&amp;gt;$MPElement[Name="System!System.Entity"]/DisplayName$&amp;lt;/Property&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/ValueExpression&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Operator&amp;gt;Equal&amp;lt;/Operator&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ValueExpression&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Value&amp;gt;Gargantua&amp;lt;/Value&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/ValueExpression&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/SimpleExpression&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Expression&amp;gt;&lt;/FONT&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/MembershipRule&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;/MembershipRules&amp;gt;&lt;BR&gt;
&lt;P&gt;We only care about the section highlighted in blue.&amp;nbsp; That's the part of the membership rule that we want to move to our component group discovery.&amp;nbsp; We can simply copy it out and then paste it over the IncludeList section.&lt;/P&gt;
&lt;P&gt;If we edit the component group discovery, then we get the following XML:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;lt;RuleId&amp;gt;$MPElement$&amp;lt;/RuleId&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;GroupInstanceId&amp;gt;$Target/Id$&amp;lt;/GroupInstanceId&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;MembershipRules&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;MembershipRule&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;MonitoringClass&amp;gt;$MPElement[Name="System!System.WebSite"]$&amp;lt;/MonitoringClass&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;RelationshipClass&amp;gt;$MPElement[Name="MicrosoftSystemCenterServiceDesignerLibrary6062460!Microsoft.SystemCenter.ServiceDesigner.WebSiteGroupContainsWebSite"]$&amp;lt;/RelationshipClass&amp;gt;&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;IncludeList&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;MonitoringObjectId&amp;gt;{fea25c09-8877-dcf3-5f1a-a67a03ffb34d}&amp;lt;/MonitoringObjectId&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;MonitoringObjectId&amp;gt;{4dd57b21-d581-ad4e-36b5-eafc3eeb6994}&amp;lt;/MonitoringObjectId&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/IncludeList&amp;gt;&lt;/FONT&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/MembershipRule&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;/MembershipRules&amp;gt;&lt;BR&gt;&lt;/P&gt;
&lt;P&gt;In this case, the blue section is the one we want to overwrite with the Expression from the group discovery.&amp;nbsp; If we do that, we get the following XML which we can then save back into the component group discovery rule:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;lt;RuleId&amp;gt;$MPElement$&amp;lt;/RuleId&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;GroupInstanceId&amp;gt;$Target/Id$&amp;lt;/GroupInstanceId&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;MembershipRules&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;MembershipRule&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;MonitoringClass&amp;gt;$MPElement[Name="System!System.WebSite"]$&amp;lt;/MonitoringClass&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;RelationshipClass&amp;gt;$MPElement[Name="MicrosoftSystemCenterServiceDesignerLibrary6062460!Microsoft.SystemCenter.ServiceDesigner.WebSiteGroupContainsWebSite"]$&amp;lt;/RelationshipClass&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Expression&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;SimpleExpression&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ValueExpression&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Property&amp;gt;$MPElement[Name="System!System.Entity"]/DisplayName$&amp;lt;/Property&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/ValueExpression&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Operator&amp;gt;Equal&amp;lt;/Operator&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ValueExpression&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Value&amp;gt;Gargantua&amp;lt;/Value&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/ValueExpression&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/SimpleExpression&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Expression&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/MembershipRule&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;/MembershipRules&amp;gt;&lt;BR&gt;
&lt;P&gt;If you save the management pack after this modification and then import it back into the management group, anytime a new web site is discovered with the name Gargantua it will be added to the Web Sites group in the distributed application.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;The big thing to keep in mind if you use this strategy is that you can't use the Distributed Applications Designer for that application anymore.&amp;nbsp; If you edit and save it, you're going to overwrite that custom discovery that you just created.&amp;nbsp; Obviously, the best strategy would be to create the entire application using the designer and then performing your custom modification.&lt;/P&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=2785327" width="1" height="1"&gt;</description><category domain="http://blogs.technet.com/brianwren/archive/tags/OpsMgr/default.aspx">OpsMgr</category><category domain="http://blogs.technet.com/brianwren/archive/tags/Management+Packs/default.aspx">Management Packs</category></item><item><title>Exporting Management Packs</title><link>http://blogs.technet.com/brianwren/archive/2007/08/22/exporting-management-packs.aspx</link><pubDate>Wed, 22 Aug 2007 19:33:35 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:1803505</guid><dc:creator>Brian Wren</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.technet.com/brianwren/comments/1803505.aspx</comments><wfw:commentRss>http://blogs.technet.com/brianwren/commentrss.aspx?PostID=1803505</wfw:commentRss><description>&lt;p&gt;Obviously, /a great way to learn how to author a management pack is to look at existing ones.&amp;nbsp; The problem is that most of the interesting ones are sealed so you can't read the file, and the Operations Console won't allow you to export a sealed management pack.&amp;nbsp; &lt;/p&gt; &lt;p&gt;This is actually very easy using Command Shell.&amp;nbsp; You can export a single management pack or export the entire set of installed management packs from a management group.&amp;nbsp; This is my personal favorite as I like to have the entire set of management packs available for my reference.&lt;/p&gt; &lt;p&gt;Command Shell is an optional component of the Operations Manager User Interfaces, so it's probably something you already have installed.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Exporting a single management pack&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;To export a single management pack, use the following command:&lt;/p&gt; &lt;p align="center"&gt;get-managementPack -name &amp;lt;Name of MP&amp;gt; | export-managementPack -path &amp;lt;Directory to store exported file&amp;gt;&lt;/p&gt; &lt;p&gt;For example, to export the SQL Library MP to a directory called c:\mp:&lt;/p&gt; &lt;p align="center"&gt;get-managementPack -name Microsoft.SQLServer.Library | export-managementPack -path c:\mp&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Exporting all management packs&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;It's actually easier to export all management packs since you don't have to specify the -name parameter on the get-managementPack CmdLet.&amp;nbsp; Just use the following, and you will fill c:\mp with the entire set of management packs installed in your management group.&lt;/p&gt; &lt;p align="center"&gt;get-managementPack | export-managementPack -path c:\mp&lt;/p&gt; &lt;p align="left"&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Update on 2/17/2008&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;I would be completely remiss if I didn't update this post to refer to Boris' PowerShell script that can convert an MP file to XML from a command line.&amp;nbsp; Certainly easier if you need to convert a sealed management pack that you don't already have imported into a management group.&amp;nbsp; &lt;/p&gt; &lt;p&gt;&lt;a title="http://blogs.msdn.com/boris_yanushpolsky/archive/2007/08/16/unsealing-a-management-pack.aspx" href="http://blogs.msdn.com/boris_yanushpolsky/archive/2007/08/16/unsealing-a-management-pack.aspx"&gt;http://blogs.msdn.com/boris_yanushpolsky/archive/2007/08/16/unsealing-a-management-pack.aspx&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=1803505" width="1" height="1"&gt;</description><category domain="http://blogs.technet.com/brianwren/archive/tags/OpsMgr/default.aspx">OpsMgr</category><category domain="http://blogs.technet.com/brianwren/archive/tags/Command+Shell/default.aspx">Command Shell</category><category domain="http://blogs.technet.com/brianwren/archive/tags/Management+Packs/default.aspx">Management Packs</category></item><item><title>Targeting Rules and Monitors</title><link>http://blogs.technet.com/brianwren/archive/2007/08/22/targeting-rules-and-monitors.aspx</link><pubDate>Wed, 22 Aug 2007 19:33:12 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:1803503</guid><dc:creator>Brian Wren</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.technet.com/brianwren/comments/1803503.aspx</comments><wfw:commentRss>http://blogs.technet.com/brianwren/commentrss.aspx?PostID=1803503</wfw:commentRss><description>&lt;p&gt;The concept of what target to use for a particular rule or monitor in OpsMgr 2007&amp;nbsp;seems to be one that people are struggling with.&amp;nbsp; The confusion is most prevelant among people who have had experience with MOM 2005 since the methods have completely in changed.&amp;nbsp; In MOM 2005, you would apply rule groups to computer groups.&amp;nbsp; If a computer was in the group, it would get the rule - it was that simple. In OpsMgr 2007, we do not use groups to target rules/monitors.&amp;nbsp; What adds to the confusion though is that groups are available in the list of targets when creating a rule/monitor in the console.&amp;nbsp; Let's see if I can explain this.&lt;/p&gt; &lt;p&gt;The main conceptual difference between MOM 2005 and OpsMgr 2007 in this respect is that in MOM 2005 we thought about which computer we would retrieve a particular piece of information from, and we targeted rules at groups containing those computers.&amp;nbsp; We had to think about the individual agents and view the environment in terms of the physical computers being managed.&amp;nbsp; We had formulas for the groups to identify which computers held different components, but we were ultimately targeting groups of agents.&amp;nbsp; In OpsMgr 2007, we think about what component is generating the information.&amp;nbsp; That’s a distinctly different concept and ultimately more powerful.&amp;nbsp; OpsMgr will figure out which agents hold instances of that component, deliver the rule/monitor to the appropriate agents, and execute the rule/monitor for each instance.&amp;nbsp; &lt;/p&gt; &lt;p&gt;In 2007, we also work against multiple instances of a class on a particular agent.&amp;nbsp; In MOM 2005, we only had a single rule sent to the agent, and that rule had to do the enumeration.&amp;nbsp; A good example is SQL databases.&amp;nbsp; The SQL scripts in MOM 2005 were enormous because they had to enumerate the whole list of databases and other SQL objects every single time they executed.&amp;nbsp; In 2007, we just apply those rules to the SQL Database class, and OpsMgr executes the rule for each database instance discovered.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;How does a rule get to an agent?&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;For any particular rule/monitor, OpsMgr will enumerate all instances of the target class and apply the rule to each.&amp;nbsp; If there are no instances of the target class on a particular agent, then the rule will do nothing.&amp;nbsp; It's that simple.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;If I can't target groups, why are they listed when I select a target for a rule?&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Groups are classes just like any other.&amp;nbsp; They’re singleton classes where the class and the instance are one and the same, but they are classes nonetheless which is why they show up in the list with all other classes.&amp;nbsp;&amp;nbsp; There are really very few circumstances where you will target a rule at a group though&lt;strong&gt;.&lt;/strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;What if I do target a group?&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;You can apply a rule/monitor directly to a group, but it will execute against the group object&amp;nbsp;itself.&amp;nbsp; OpsMgr will not enumerate members of the group and apply the rule to each.&amp;nbsp;&amp;nbsp;Any rules targeted at groups will actually operate on the Root Management Server since&amp;nbsp;groups have no host and unhosted objects are&amp;nbsp;managed by the RMS.&amp;nbsp; &lt;/p&gt; &lt;p&gt;&lt;strong&gt;How do I target some group of objects then?&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;To the specific question of how to get a particular rule/monitor to a subset of components, you have two basic options.&amp;nbsp; Let’s say for example, you have a particular subset of web sites that you need a particular rule to apply.&amp;nbsp; You could target that rule at the IIS 2003 Web Site class for example, but that would apply the rule to all instances of that class.&amp;nbsp; It would probably apply to sites that you didn’t want.&lt;/p&gt; &lt;p&gt;Option 1 would be to create a new class and target the rule at the class.&amp;nbsp; In the case of an IIS site, this would mean that you would need to go to the Authoring Console or raw XML and create a new class and discovery.&amp;nbsp; That’s a more advanced solution that most customers will do and probably overkill anyway.&amp;nbsp; &lt;/p&gt; &lt;p&gt;Option 2 is the create a rule target at the whole class and disable it.&amp;nbsp; Create a group with the sites you want and create an override for that group to enable your rule.&amp;nbsp; This&amp;nbsp;might sound like a workaround, but&amp;nbsp;it's a completely valid solution.&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;How do I know&amp;nbsp;if I'm selecting the right target?&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;The easiest method to validate you are using a target that actually has instances is to use the Discovered Inventory view in the Operations Console prior to creating your rule/monitor.&amp;nbsp;In the Actions pane is an option called "Change target type..." that will bring up the same Select a Target Type dialog box that you see when you select the target for a rule/monitor.&amp;nbsp; This view will list all instances of the target class you select.&amp;nbsp; You can validate which agents have an instance of that class and how many instances&amp;nbsp;each has.&amp;nbsp; If there are no instances listed, then the rule isn't going to do anything.&amp;nbsp; If there are instances, then you not only be confident that the rule/monitor will&amp;nbsp;execute on the agent, but you&amp;nbsp;can also view the properties of the instance that will be accessible to any rules/monitors targeted at it.&lt;/p&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=1803503" width="1" height="1"&gt;</description><category domain="http://blogs.technet.com/brianwren/archive/tags/OpsMgr/default.aspx">OpsMgr</category><category domain="http://blogs.technet.com/brianwren/archive/tags/Management+Packs/default.aspx">Management Packs</category></item></channel></rss>