<?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</title><link>http://blogs.technet.com/brianwren/default.aspx</link><description>Operations Manager management packs and other automation technologies</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Sample Application for SP1</title><link>http://blogs.technet.com/brianwren/archive/2009/06/04/sample-application-for-sp1.aspx</link><pubDate>Fri, 05 Jun 2009 09:28:00 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3250645</guid><dc:creator>Brian Wren</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.technet.com/brianwren/comments/3250645.aspx</comments><wfw:commentRss>http://blogs.technet.com/brianwren/commentrss.aspx?PostID=3250645</wfw:commentRss><description>&lt;P&gt;Attached to this post is a version of my sample application for Operations Manager SP1.&amp;nbsp; This has the process monitor removed that relies on the modules in R2.&amp;nbsp; &lt;/P&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3250645" width="1" height="1"&gt;</description><enclosure url="http://blogs.technet.com/brianwren/attachment/3250645.ashx" length="102479" type="text/xml" /></item><item><title>PowerShell Scripts in a Management Pack Part 2</title><link>http://blogs.technet.com/brianwren/archive/2009/06/04/powershell-scripts-in-a-management-pack-part-2.aspx</link><pubDate>Fri, 05 Jun 2009 08:49:00 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3250626</guid><dc:creator>Brian Wren</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.technet.com/brianwren/comments/3250626.aspx</comments><wfw:commentRss>http://blogs.technet.com/brianwren/commentrss.aspx?PostID=3250626</wfw:commentRss><description>&lt;P&gt;In a &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;, I explained how to run PowerShell scripts from a management pack.&amp;nbsp; I honestly don’t remember why I titled that “Part 1” because I don’t remember what I figured that Part 2 was going to be.&amp;nbsp; Turns out that using the native PowerShell modules in OpsMgr R2 is a perfect topic for Part 2 which I’ll present here (just pretend that I meant that all along).&amp;nbsp; &lt;/P&gt;
&lt;P&gt;Prior to R2 we could launch PowerShell scripts from a management pack, but we had to do it by building the command line and launching powershell.exe.&amp;nbsp; This was more complicated, less efficient, and had the disadvantage that the agent didn’t actually know that it was running a script.&amp;nbsp; If that script hit an error, we didn’t know about because the agent simply knew that it successfully launched the executable.&amp;nbsp; Now that we have a native module, this is going to be much more efficient and reliable.&amp;nbsp; I had some disclaimers in that post about overhead from PowerShell that don’t apply with the new modules.&amp;nbsp; Keep in mind that PowerShell still has to be installed on the target agent.&lt;/P&gt;
&lt;P&gt;There are some different details to know about using these modules though, and that’s exactly the point of this post.&amp;nbsp; I updated my sample application with PowerShell equivalents of a discovery and a property bag script, so you might want to grab that to have as a reference as you read through the rest of this post.&lt;/P&gt;
&lt;H1&gt;Scripts&lt;/H1&gt;
&lt;H3&gt;&lt;/H3&gt;
&lt;P&gt;In the last post I mentioned that the scripts don’t really change from their VBScript counterparts.&amp;nbsp; We still create discovery data and property bags using the MOM.ScriptAPI object – we’ll just need to use the New-Object cmdlet in PowerShell instead of the CreateObject method in VBScript.&amp;nbsp; That’s really the only difference when we were calling PowerShell.exe with the Command, but there are some other changes we’re going to need when using the native R2 modules.&amp;nbsp; &lt;/P&gt;
&lt;H2&gt;Parameters&lt;/H2&gt;
&lt;H3&gt;&lt;/H3&gt;
&lt;P&gt;The first change is how we are going to accept parameters into the script.&amp;nbsp; Note that the term “parameter” is going to get a little tricky here.&amp;nbsp; Modules have parameters, and we can pass parameters to a script.&amp;nbsp; As you’ll see below, the PowerShell modules have a module parameter called Parameter to make things even more confusing.&amp;nbsp; I’ll do my best to keep the wording clear though, and you shouldn’t have too tough of a time sorting all of this out.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;I’ll show how to pass the values to the script parameters below, but for now let’s just worry about the script itself.&amp;nbsp; Instead of accessing positional arguments with the $args variable (the equivalent of WScript.Arguments in VBScript) we’re going to use named parameters.&amp;nbsp; We accept these into the script using the param() command at the start of the script specifying the variables that the script is accepting the parameters into.&lt;/P&gt;
&lt;P&gt;For example, for the queue statistics script in my sample application, we need to pass in two parameters - $topFolder and $debug.&amp;nbsp; We do that with the following line:&lt;/P&gt;
&lt;DIV align=center&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;param&lt;/SPAN&gt;($topFolder,$debug)&lt;/PRE&gt;&lt;/DIV&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 align=left&gt;This would allow us to specify named parameters on the command line when executing the script.&amp;nbsp; This would look something like below for the Queue Statistics script.&lt;/P&gt;
&lt;DIV align=center&gt;&lt;PRE class=csharpcode&gt;.\QueueStats.ps1 -topFolder &lt;SPAN class=str&gt;'C:\StoreQueues'&lt;/SPAN&gt; –debug $false&lt;/PRE&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;
&lt;P&gt;We might type that command line when testing the script, but we won’t be putting it into the management pack – I’ll show how we do that below.&amp;nbsp; Just want to give you a basic idea of how PowerShell works with named parameters if you aren’t already familiar with it.&lt;/P&gt;
&lt;H2&gt;Returning Data&lt;/H2&gt;
&lt;P align=left&gt;In VBScript, we return data using the Return method on the MOM.ScriptAPI object if we are returning discovery data or a single property bag.&amp;nbsp; If we are returning multiple property bags, we use ReturnItems().&amp;nbsp; Those aren’t going to work very well from the R2 PowerShell modules though.&amp;nbsp; Instead, we can simply return the objects themselves from the script.&amp;nbsp; In PowerShell, you do this by typing the name of the variable on a line all by itself.&lt;/P&gt;
&lt;P align=left&gt;This is best illustrated by the following examples which show the PowerShell equivalent to a VBScript snippet:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P align=left&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P align=center&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;TABLE border=0 cellSpacing=0 cellPadding=2 width=681&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=347&gt;&lt;STRONG&gt;Discovery Data&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD vAlign=top width=332&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=347&gt;VBScript&lt;/TD&gt;
&lt;TD vAlign=top width=332&gt;PowerShell&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=347&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;PRE class=csharpcode&gt;Set oAPI = CreateObject(&lt;SPAN class=str&gt;"MOM.ScriptAPI"&lt;/SPAN&gt;) 
Set oDiscoveryData = oAPI.CreateDiscoveryData() 
… 
… 
oAPI.Return(oDiscoveryData)&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;/FONT&gt;&lt;/TD&gt;
&lt;TD vAlign=top width=332&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;PRE class=csharpcode&gt;$api = New-Object -comObject &lt;SPAN class=str&gt;'MOM.ScriptAPI'&lt;/SPAN&gt; 
$discoveryData = $api.CreateDiscoveryData() 
… 
… 
$discoveryData&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;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=347&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD vAlign=top width=332&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=347&gt;&lt;STRONG&gt;Single Property Bag&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD vAlign=top width=332&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=347&gt;VBScript&lt;/TD&gt;
&lt;TD vAlign=top width=332&gt;PowerShell&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=347&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;PRE class=csharpcode&gt;Set oAPI = CreateObject(&lt;SPAN class=str&gt;"MOM.ScriptAPI"&lt;/SPAN&gt;) 
Set oBag = oAPI.CreatePropertyBag() 
… 
… 
oAPI.Return(oBag)&lt;/PRE&gt;&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD vAlign=top width=332&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;PRE class=csharpcode&gt;$api = New-Object -comObject &lt;SPAN class=str&gt;'MOM.ScriptAPI'&lt;/SPAN&gt; 
$bag = $api.CreatePropertyBag() 
… 
… 
$bag&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;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=347&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD vAlign=top width=332&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=347&gt;&lt;STRONG&gt;Multiple Property Bags&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD vAlign=top width=332&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=347&gt;VBScript&lt;/TD&gt;
&lt;TD vAlign=top width=332&gt;PowerShell&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=347&gt;&lt;PRE class=csharpcode&gt;Set oAPI = CreateObject(&lt;SPAN class=str&gt;"MOM.ScriptAPI"&lt;/SPAN&gt;) 
For Each object &lt;SPAN class=kwrd&gt;in&lt;/SPAN&gt; collection 
    Set oBag = oAPI.CreatePropertyBag() 
    … 
    … 
Next 
oAPI.ReturnItems()&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;/TD&gt;
&lt;TD vAlign=top width=332&gt;&lt;PRE class=csharpcode&gt;$api = New-Object -comObject &lt;SPAN class=str&gt;'MOM.ScriptAPI'&lt;/SPAN&gt; 
&lt;SPAN class=kwrd&gt;foreach&lt;/SPAN&gt; (object &lt;SPAN class=kwrd&gt;in&lt;/SPAN&gt; collection) 
{ 
    $bag = $api.CreatePropertyBag() 
    … 
    … 
    $bag 
}&lt;/PRE&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Note that in the multiple property bag example, we’re simply returning each bag as we create it. That’s not complicated but certainly a different approach than in VBScript where we stack up all of the objects before returning them at once with ReturnItems().&amp;nbsp; The condition detection or write action that is going to accept the output will work against each property bag returned from the script.&amp;nbsp; The end result is identical to using ReturnItems() in VBScript – just looks a little different in the script.&lt;/P&gt;
&lt;P&gt;&lt;FONT face=ver&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;H2&gt;Consoles&lt;/H2&gt;
&lt;P&gt;The PowerShell modules will not be accessible in the Operations Console in R2 (no word yet if they will be in future releases).&amp;nbsp; You are still going to be limited to writing scripts with VBScript or JScript if you are living only in that console.&lt;/P&gt;
&lt;P&gt;You will be able to use the new modules in the Authoring Console, although wizards aren’t going to be available for them.&amp;nbsp; You aren’t going to be able to simply select New Rule and see something like Timed PowerShell Script.&amp;nbsp; You’re going to have to create custom modules, monitor types, monitors, and rules if you want to use the PowerShell modules.&amp;nbsp; For creating workflows based on scripts this is typically what you want to do anyway to be able to use your script in multiple workflows and to present a nice set of overrideable parameters to the operator.&amp;nbsp; Really shouldn’t be much more complicated than other custom modules that you’ve built. &lt;/P&gt;
&lt;H1&gt;Modules&lt;/H1&gt;
&lt;H2&gt;Discoveries&lt;/H2&gt;
&lt;H2&gt;&lt;/H2&gt;
&lt;P&gt;There is only a single data source module for executing PowerShell scripts -&amp;nbsp; Microsoft.Windows.TimedPowerShell.DiscoveryProvider.&amp;nbsp; This is the functional equivalent of the timed script discovery provider that you’ve probably used for creating a discovery with VBScript.&amp;nbsp; I’m not going to list out all the parameters for the module since you’ll be familiar with most of them – IntervalSeconds, ScriptName, ScriptBody, etc.&amp;nbsp; The new ones are going to be SnapIns and Parameters which I’ll get to below.&lt;/P&gt;
&lt;P&gt;No real trick to using the module other than defining the new parameters.&amp;nbsp; You’ll create a new discovery with that data source, plug in your script, and you’re on your way.&lt;/P&gt;
&lt;H2&gt;Property Bags&lt;/H2&gt;
&lt;P&gt;Scripts returning property bags are used for most monitors and rules using scripts.&amp;nbsp; These are going to be trickier than the discovery scripts using R2 because we don’t have a data source module.&amp;nbsp; We do have a probe action though called Microsoft.Windows.PowerShellPropertyBagProbe, so it’s a matter of creating a data source module using it and a System.Scheduler.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;In the sample application, I have three data source modules for PowerShell property bag scripts as follows:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Demo.StoreApp.TimedPowerShell.PropertyBagProvider &lt;/LI&gt;
&lt;LI&gt;Demo.StoreApp.TimedPowerShell.EventProvider &lt;/LI&gt;
&lt;LI&gt;Demo.StoreApp.TimedPowerShell.PerformanceProvider &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;I’m not going to go into the details of each – you can have a look at the them yourself.&amp;nbsp; They are the functional equivalents of the TimedScript modules in the Windows Library management pack.&amp;nbsp; The first returns a property bag while the other two use the first one and then map the property bag output to either an event or perf data.&lt;/P&gt;
&lt;H1&gt;New Parameters&lt;/H1&gt;
&lt;H2&gt;Parameters Parameter&lt;/H2&gt;
&lt;P&gt;Yes I know, a parameter called Parameters – sounds a little tricky.&amp;nbsp; Actually pretty straightforward though.&amp;nbsp; We have a module parameter that defines the script parameters that are going to be passed to our PowerShell script.&amp;nbsp; This replaces the Arguments parameter on the VBScript modules and provides a more structured definition of the arguments being passed to the script.&lt;/P&gt;
&lt;H2&gt;&lt;/H2&gt;
&lt;P&gt;The other thing that’s going to make this a bit tricky is that we’re going to have to directly edit the XML in order to provide the parameters.&amp;nbsp; The structure is pretty simple, but you may not be familiar with launching an external editor from the Authoring Console.&amp;nbsp; I’m not going to go into the details of that here, but I may do another blog post on it.&amp;nbsp; It may seem a bit confusing how to do this and also why you have to.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;The structure is pretty simple as you can see from the example below – just a matter of providing a name and value for each parameter.&amp;nbsp; This is for the queue discovery in my sample application.&lt;/P&gt;&lt;PRE class=csharpcode&gt;&amp;lt;Parameters&amp;gt; 
  &amp;lt;Parameter&amp;gt; 
    &amp;lt;Name&amp;gt;sourceID&amp;lt;/Name&amp;gt; 
    &amp;lt;Value&amp;gt;$MPElement$&amp;lt;/Value&amp;gt; 
  &amp;lt;/Parameter&amp;gt; 
  &amp;lt;Parameter&amp;gt; 
    &amp;lt;Name&amp;gt;managedEntityID&amp;lt;/Name&amp;gt; 
    &amp;lt;Value&amp;gt;$Target/Id$&amp;lt;/Value&amp;gt; 
  &amp;lt;/Parameter&amp;gt; 
  &amp;lt;Parameter&amp;gt; 
    &amp;lt;Name&amp;gt;topFolder&amp;lt;/Name&amp;gt; 
    &amp;lt;Value&amp;gt;$Target/Property[Type=&lt;SPAN class=str&gt;"Demo.StoreApp.ComputerRole.CentralServer"&lt;/SPAN&gt;]/QueuePath$&amp;lt;/Value&amp;gt; 
  &amp;lt;/Parameter&amp;gt; 
  &amp;lt;Parameter&amp;gt; 
    &amp;lt;Name&amp;gt;computerName&amp;lt;/Name&amp;gt; 
    &amp;lt;Value&amp;gt;$Target/Host/Property[Type=&lt;SPAN class=str&gt;"Windows!Microsoft.Windows.Computer"&lt;/SPAN&gt;]/PrincipalName$&amp;lt;/Value&amp;gt; 
  &amp;lt;/Parameter&amp;gt; 
  &amp;lt;Parameter&amp;gt; 
    &amp;lt;Name&amp;gt;debug&amp;lt;/Name&amp;gt; 
    &amp;lt;Value&amp;gt;$true&amp;lt;/Value&amp;gt; 
  &amp;lt;/Parameter&amp;gt; 
&amp;lt;/Parameters&amp;gt; &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;The first line of the script this module would be calling is the following Param command which collects each of the named parameters.&lt;/P&gt;
&lt;P align=center&gt;&lt;FONT face="Courier New"&gt;param($sourceId,$managedEntityId,$topFolder,$computerName,$debug)&lt;/FONT&gt;&lt;/P&gt;
&lt;P align=left&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;H2&gt;Snap Ins Parameter&lt;/H2&gt;
&lt;P&gt;The other parameter is to define snap ins that your script requires.&amp;nbsp; Your script may not need any in which case you won’t use this parameter.&amp;nbsp; I don’t have in my sample application since those scripts just use the file system.&amp;nbsp; To show an example of the parameter though, consider a script that requires access to Operations Manager data – something you might run from a Management Server.&amp;nbsp; That would require the client snap-in which is called Microsoft.EnterpriseManagement.OperationsManager.Client.&amp;nbsp; To specify this snap-in for your script, you would use the following &lt;/P&gt;&lt;PRE class=csharpcode&gt;&amp;lt;SnapIns&amp;gt;
  &amp;lt;SnapIn&amp;gt;Microsoft.EnterpriseManagement.OperationsManager.Client&amp;lt;/SnapIn&amp;gt;
&amp;lt;/SnapIns&amp;gt;&lt;/PRE&gt;
&lt;H2&gt;Samples&lt;/H2&gt;
&lt;P&gt;Rather than paste a bunch of XML in here, you can just grab the latest version of the sample application attached to the post.&amp;nbsp; I have a discovery script and property bag script in there that have plenty of comments.&amp;nbsp; I haven’t updated the document yet, but I’ll get to that.&amp;nbsp; I didn’t want to hold off on the post.&lt;/P&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;img src="http://blogs.technet.com/aggbug.aspx?PostID=3250626" width="1" height="1"&gt;</description><enclosure url="http://blogs.technet.com/brianwren/attachment/3250626.ashx" length="135222" type="text/xml" /></item><item><title>Sample Application Dependencies</title><link>http://blogs.technet.com/brianwren/archive/2009/05/19/sample-application-dependencies.aspx</link><pubDate>Wed, 20 May 2009 08:25:00 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3243596</guid><dc:creator>Brian Wren</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.technet.com/brianwren/comments/3243596.aspx</comments><wfw:commentRss>http://blogs.technet.com/brianwren/commentrss.aspx?PostID=3243596</wfw:commentRss><description>&lt;p&gt;I’ve had a couple of people tell me that the sample application I used for my MMS presentations won’t load in their environment.&amp;#160; That’s because the management pack requires the OpsMgr R2 beta.&amp;#160; It won’t load into an SP1 management group.&amp;#160; I used a monitor in there from the new process monitoring MP in R2.&amp;#160; &lt;/p&gt;  &lt;p&gt;I’m about to update the MP with some PowerShell examples.&amp;#160; When I do, I’ll strip out the process monitoring in the original version and have a second version that can load into SP1 for those people without access to an R2 environment. Should just be a couple of days before I get that done.&lt;/p&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3243596" width="1" height="1"&gt;</description></item><item><title>R2 Authoring Console</title><link>http://blogs.technet.com/brianwren/archive/2009/05/07/r2-authoring-console.aspx</link><pubDate>Thu, 07 May 2009 19:16:29 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3236983</guid><dc:creator>Brian Wren</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.technet.com/brianwren/comments/3236983.aspx</comments><wfw:commentRss>http://blogs.technet.com/brianwren/commentrss.aspx?PostID=3236983</wfw:commentRss><description>&lt;p&gt;I’ve been getting this question quite a bit, so I thought I’d give a quick answer to it.&amp;#160; The question is whether we can use the R2 Authoring Console to create management packs for SP1.&amp;#160; The answer is that you absolutely can – with a minor caveat.&amp;#160; There is nothing different about the structure of a management pack for SP1 or R2, and the Authoring Console just creates management packs in XML.&amp;#160; There are R2 specific modules, and using those will make your MP unusable in SP1, but you could use those with any version of the Authoring Console or even editing XML directly.&lt;/p&gt;  &lt;p&gt;But what about that one caveat?&amp;#160; When you create a new management pack in the Authoring Console, it will automatically add references to the library MPs – System.Library, System.Health.Library, Microsoft.Windows.Library, and Microsoft.SystemCenter.Library.&amp;#160; The R2 Authoring Console will create those references to the latest versions of those MPs (6.1.7043.0 as of RC version of R2).&amp;#160; You probably aren’t going to use any specific features of those new versions, but if you leave those references, your management pack won’t load in a management group with pre-R2 libraries.&amp;#160; &lt;/p&gt;  &lt;p&gt;To fix this, you should be able to just go to the References tab in Management Pack Properties and change the versions of those references.&amp;#160; The Key Token won’t change since the same certificate was used for sealing the different MP versions.&amp;#160; For reference, the SP1 libraries are version 6.0.6278.0, and the RTM libraries are version 6.0.5000.0.&lt;/p&gt;  &lt;p&gt;Bottom line is definitely use the R2 Authoring Console regardless of which version of OpsMgr you’re working with.&amp;#160; Several improvements over the SP1 version including the ability to create elements that we used to have to drop out to XML for.&lt;/p&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3236983" width="1" height="1"&gt;</description></item><item><title>MMS 2009</title><link>http://blogs.technet.com/brianwren/archive/2009/04/28/mms-2009.aspx</link><pubDate>Wed, 29 Apr 2009 03:44:43 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3232238</guid><dc:creator>Brian Wren</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.technet.com/brianwren/comments/3232238.aspx</comments><wfw:commentRss>http://blogs.technet.com/brianwren/commentrss.aspx?PostID=3232238</wfw:commentRss><description>&lt;p&gt;A bit wiped out after delivering four consecutive sessions on management pack authoring.&amp;#160; I'm impressed with people who made it through the entire five hours.&amp;#160; That was definitely not light content.&amp;#160; Seems like they were well received though.&amp;#160; &lt;/p&gt;  &lt;p&gt;The sample management&amp;#160; pack that I showed along with a document describing&amp;#160; the MP and the sample application that it's based on is on the &lt;a href="http://www.opsmanjam.com/Lists/OpsManJam%20Announcements/DispForm.aspx?ID=13"&gt;OpsManJam&lt;/a&gt; site.&amp;#160; I'm planning on continuously updating this MP as l create other example scenarios.&amp;#160; I thought that would be more interesting than continuing to do random examples, and l can keep them all packaged up in one clean MP.&amp;#160; I'm also getting tired of all the random little XML files l have cluttering up my MP library.&lt;/p&gt;  &lt;p&gt;I'm getting mocked quite a bit at the conference about my lack of blog updates.&amp;#160; Now that I've gotten through these presentations as well as some other training l was working on, l should be able to get to that.&lt;/p&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3232238" width="1" height="1"&gt;</description></item><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>Programmatically Creating Groups</title><link>http://blogs.technet.com/brianwren/archive/2008/11/18/programmatically-creating-groups.aspx</link><pubDate>Tue, 18 Nov 2008 11:04:27 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3155696</guid><dc:creator>Brian Wren</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.technet.com/brianwren/comments/3155696.aspx</comments><wfw:commentRss>http://blogs.technet.com/brianwren/commentrss.aspx?PostID=3155696</wfw:commentRss><description>&lt;p&gt;Well, it looks from my last post that I took about a eight month hiatus from the blog.&amp;#160; Fortunately, I've been doing a bunch of OpsMgr in that time, so I have a bunch of content to get out here.&amp;#160; Just a matter of taking the time to write it up.&lt;/p&gt;  &lt;p&gt;The one I'll go with first is programmatically creating groups.&amp;#160; Now creating a single group is pretty easy in the Operations Console, so creating a single one from a command line isn't going to get anyone excited.&amp;#160; What is exciting though is if you have a bunch of groups to create - especially if several of these are subgroups.&lt;/p&gt;  &lt;p&gt;I'll leave you to figure out the complexity of providing a list of groups - maybe reading from a text file or something.&amp;#160; That's just straight PowerShell work.&amp;#160; What I will give you though is the code to create a new group.&amp;#160; You should be able to use this base code to do whatever complex and repetitive group creation that you might need.&lt;/p&gt;  &lt;p&gt;First of all, there is no cmdlet to create a group.&amp;#160; You're going to have to manually create a Microsoft.EnterpriseManagement.Monitoring.CustomMonitoringObjectGroup object, set its properties, and then save it to the management group using the InsertCustomMonitoringObjectGroup method on the management group.&amp;#160; That part's easy.&amp;#160; It will be when I give you the code in a minute anyway.&amp;#160; The tough part of the exercise is setting the membership formula, and we need to go through that before we get into the code.&lt;/p&gt;  &lt;h2&gt;Membership Formula&lt;/h2&gt;  &lt;p&gt;The membership formula is an XML expression defining the logic for what objects should be members of the group.&amp;#160; The easiest way to figure out how to build this formula is to configure a group using the dialog box in the Operations Console and then copy out the resulting XML.&amp;#160; There are a couple of things you need to know about this though,&amp;#160; so let me provide a bit of explanation and a couple of examples.&lt;/p&gt;  &lt;p&gt;When you export the management pack, you'll find the membership rule in the discovery for the group.&amp;#160; It might take you a little bit of searching through the different discoveries if you aren't familiar with the XML schema of a management pack, but it shouldn't take too long.&amp;#160; A typical discovery will look something like the XML below.&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&amp;lt;Discovery ID=&lt;span class="str"&gt;&amp;quot;UINameSpace9e378de9416945c4820c4cacfd0475fa.Group.DiscoveryRule&amp;quot;&lt;/span&gt; Enabled=&lt;span class="str"&gt;&amp;quot;true&amp;quot;&lt;/span&gt; Target=&lt;span class="str"&gt;&amp;quot;UINameSpace9e378de9416945c4820c4cacfd0475fa.Group&amp;quot;&lt;/span&gt; ConfirmDelivery=&lt;span class="str"&gt;&amp;quot;false&amp;quot;&lt;/span&gt; Remotable=&lt;span class="str"&gt;&amp;quot;true&amp;quot;&lt;/span&gt; Priority=&lt;span class="str"&gt;&amp;quot;Normal&amp;quot;&lt;/span&gt;&amp;gt; 
  &amp;lt;Category&amp;gt;Discovery&amp;lt;/Category&amp;gt; 
  &amp;lt;DiscoveryTypes&amp;gt; 
    &amp;lt;DiscoveryRelationship TypeID=&lt;span class="str"&gt;&amp;quot;SCIG!Microsoft.SystemCenter.InstanceGroupContainsEntities&amp;quot;&lt;/span&gt; /&amp;gt; 
  &amp;lt;/DiscoveryTypes&amp;gt; 
  &amp;lt;DataSource ID=&lt;span class="str"&gt;&amp;quot;GroupPopulationDataSource&amp;quot;&lt;/span&gt; TypeID=&lt;span class="str"&gt;&amp;quot;SystemCenter!Microsoft.SystemCenter.GroupPopulator&amp;quot;&lt;/span&gt;&amp;gt; 
    &amp;lt;RuleId&amp;gt;$MPElement$&amp;lt;/RuleId&amp;gt; 
    &amp;lt;GroupInstanceId&amp;gt;$MPElement[Name=&lt;span class="str"&gt;&amp;quot;UINameSpace9e378de9416945c4820c4cacfd0475fa.Group&amp;quot;&lt;/span&gt;]$&amp;lt;/GroupInstanceId&amp;gt; 
    &amp;lt;MembershipRules&amp;gt; 
      &amp;lt;MembershipRule&amp;gt; 
        &amp;lt;MonitoringClass&amp;gt;$MPElement[Name=&lt;span class="str"&gt;&amp;quot;SCIG!Microsoft.SystemCenter.InstanceGroup&amp;quot;&lt;/span&gt;]$&amp;lt;/MonitoringClass&amp;gt; 
        &amp;lt;RelationshipClass&amp;gt;$MPElement[Name=&lt;span class="str"&gt;&amp;quot;SCIG!Microsoft.SystemCenter.InstanceGroupContainsEntities&amp;quot;&lt;/span&gt;]$&amp;lt;/RelationshipClass&amp;gt; 
        &amp;lt;IncludeList&amp;gt; 
          &amp;lt;MonitoringObjectId&amp;gt;d47ea9a0-a039-d399-bec3-4b305269b57e&amp;lt;/MonitoringObjectId&amp;gt; 
        &amp;lt;/IncludeList&amp;gt; 
      &amp;lt;/MembershipRule&amp;gt; 
    &amp;lt;/MembershipRules&amp;gt; 
  &amp;lt;/DataSource&amp;gt; 
&amp;lt;/Discovery&amp;gt;&lt;/pre&gt;

&lt;p&gt;The only part you want is the MembershipRules section, and that’s what I’ll describe below.&lt;/p&gt;

&lt;h2&gt;&lt;/h2&gt;

&lt;h2&gt;Membership Formula Examples&lt;/h2&gt;

&lt;h3&gt;&lt;/h3&gt;

&lt;p&gt;First, let's look at a typical dynamic membership.&amp;#160; The following dialog box shows a criteria that you might create.&lt;/p&gt;

&lt;p align="center"&gt;&lt;a href="http://blogs.technet.com/blogfiles/brianwren/WindowsLiveWriter/ProgrammaticallyCreatingGroups_127CF/image_6.png"&gt;&lt;img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="image" src="http://blogs.technet.com/blogfiles/brianwren/WindowsLiveWriter/ProgrammaticallyCreatingGroups_127CF/image_thumb_2.png" width="433" height="353" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;That logic would translate to the following membership rule which could be used as is.&amp;#160; There are no GUIDs here to worry about.&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&amp;lt;MembershipRule&amp;gt; 
  &amp;lt;MonitoringClass&amp;gt;$MPElement[Name=&lt;span class="str"&gt;&amp;quot;Windows!Microsoft.Windows.Computer&amp;quot;&lt;/span&gt;]$&amp;lt;/MonitoringClass&amp;gt; 
  &amp;lt;RelationshipClass&amp;gt;$MPElement[Name=&lt;span class="str"&gt;&amp;quot;SCIG!Microsoft.SystemCenter.InstanceGroupContainsEntities&amp;quot;&lt;/span&gt;]$&amp;lt;/RelationshipClass&amp;gt; 
  &amp;lt;Expression&amp;gt; 
    &amp;lt;And&amp;gt; 
      &amp;lt;Expression&amp;gt; 
        &amp;lt;RegExExpression&amp;gt; 
          &amp;lt;ValueExpression&amp;gt; 
            &amp;lt;Property&amp;gt;$MPElement[Name=&lt;span class="str"&gt;&amp;quot;Windows!Microsoft.Windows.Computer&amp;quot;&lt;/span&gt;]/PrincipalName$&amp;lt;/Property&amp;gt; 
          &amp;lt;/ValueExpression&amp;gt; 
          &amp;lt;Operator&amp;gt;MatchesWildcard&amp;lt;/Operator&amp;gt; 
          &amp;lt;Pattern&amp;gt;lgb*&amp;lt;/Pattern&amp;gt; 
        &amp;lt;/RegExExpression&amp;gt; 
      &amp;lt;/Expression&amp;gt; 
      &amp;lt;Expression&amp;gt; 
        &amp;lt;RegExExpression&amp;gt; 
          &amp;lt;ValueExpression&amp;gt; 
            &amp;lt;Property&amp;gt;$MPElement[Name=&lt;span class="str"&gt;&amp;quot;Windows!Microsoft.Windows.Computer&amp;quot;&lt;/span&gt;]/IPAddress$&amp;lt;/Property&amp;gt; 
          &amp;lt;/ValueExpression&amp;gt; 
          &amp;lt;Operator&amp;gt;MatchesWildcard&amp;lt;/Operator&amp;gt; 
          &amp;lt;Pattern&amp;gt;10.1.*&amp;lt;/Pattern&amp;gt; 
        &amp;lt;/RegExExpression&amp;gt; 
      &amp;lt;/Expression&amp;gt; 
    &amp;lt;/And&amp;gt; 
  &amp;lt;/Expression&amp;gt; 
&amp;lt;/MembershipRule&amp;gt;&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;&amp;#160;&lt;/p&gt;

&lt;p&gt;How about a group with explicit members?&amp;#160; Now this is probably a bad example, because you probably won't pragmatically be creating groups with explicit members, but it is possible.&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p align="center"&gt;&lt;a href="http://blogs.technet.com/blogfiles/brianwren/WindowsLiveWriter/ProgrammaticallyCreatingGroups_127CF/image_8.png"&gt;&lt;img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="image" src="http://blogs.technet.com/blogfiles/brianwren/WindowsLiveWriter/ProgrammaticallyCreatingGroups_127CF/image_thumb_3.png" width="434" height="415" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;This generates the following membership rule which includes GUIDs.&amp;#160; These GUIDs really can't be swapped out though since they refer to specific objects.&amp;#160; If you were to programmatically&amp;#160; create something like this, you would presumably use Get-MonitoringObject in Command Shell to get the GUID of the object you're interested in and then add it to the XML.&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&amp;lt;MembershipRule&amp;gt; 
  &amp;lt;MonitoringClass&amp;gt;$MPElement[Name=&lt;span class="str"&gt;&amp;quot;SystemCenter!Microsoft.SystemCenter.ManagedComputer&amp;quot;&lt;/span&gt;]$&amp;lt;/MonitoringClass&amp;gt; 
  &amp;lt;RelationshipClass&amp;gt;$MPElement[Name=&lt;span class="str"&gt;&amp;quot;SCIG!Microsoft.SystemCenter.InstanceGroupContainsEntities&amp;quot;&lt;/span&gt;]$&amp;lt;/RelationshipClass&amp;gt; 
  &amp;lt;IncludeList&amp;gt; 
    &amp;lt;MonitoringObjectId&amp;gt;b3e9befe-173b-78a2-3e41-e19ecb58d9d5&amp;lt;/MonitoringObjectId&amp;gt; 
    &amp;lt;MonitoringObjectId&amp;gt;0852e1eb-f854-eb88-2f7d-a1bb0794d18f&amp;lt;/MonitoringObjectId&amp;gt; 
    &amp;lt;MonitoringObjectId&amp;gt;6e813ffe-2267-a191-ccbb-566d4ddf95bc&amp;lt;/MonitoringObjectId&amp;gt; 
    &amp;lt;MonitoringObjectId&amp;gt;98e3ee12-54c0-f14c-506c-4113bb8f1dcb&amp;lt;/MonitoringObjectId&amp;gt; 
  &amp;lt;/IncludeList&amp;gt; 
&amp;lt;/MembershipRule&amp;gt;&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;&amp;#160;&lt;/p&gt;

&lt;p&gt;Subgroups are something you very well might want to use.&amp;#160; One use of programmatically creating groups is to create a complex group structure which may contain several levels of different groups.&lt;/p&gt;

&lt;p align="center"&gt;&lt;a href="http://blogs.technet.com/blogfiles/brianwren/WindowsLiveWriter/ProgrammaticallyCreatingGroups_127CF/image_10.png"&gt;&lt;img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="image" src="http://blogs.technet.com/blogfiles/brianwren/WindowsLiveWriter/ProgrammaticallyCreatingGroups_127CF/image_thumb_4.png" width="445" height="425" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;This would generate the following XML, and in this case we would want to swap out that GUID which refers to the subgroup (Sample Group - Level 2 in the example).&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&amp;lt;MembershipRule&amp;gt; 
  &amp;lt;MonitoringClass&amp;gt;$MPElement[Name=&lt;span class="str"&gt;&amp;quot;SCIG!Microsoft.SystemCenter.InstanceGroup&amp;quot;&lt;/span&gt;]$&amp;lt;/MonitoringClass&amp;gt; 
  &amp;lt;RelationshipClass&amp;gt;$MPElement[Name=&lt;span class="str"&gt;&amp;quot;SCIG!Microsoft.SystemCenter.InstanceGroupContainsEntities&amp;quot;&lt;/span&gt;]$&amp;lt;/RelationshipClass&amp;gt; 
  &amp;lt;IncludeList&amp;gt; 
    &amp;lt;MonitoringObjectId&amp;gt;e499513e-4e67-142e-f1f6-53b24b5195bb&amp;lt;/MonitoringObjectId&amp;gt; 
  &amp;lt;/IncludeList&amp;gt; 
&amp;lt;/MembershipRule&amp;gt;&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;This would work better with the following.&amp;#160; The end result is the same since we'll still end up with the GUID of the subgroup.&amp;#160; but this example could be installed in other management groups and would make a lot more sense when working with code.&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&amp;lt;MembershipRule&amp;gt; 
  &amp;lt;MonitoringClass&amp;gt;$MPElement[Name=&lt;span class="str"&gt;&amp;quot;SCIG!Microsoft.SystemCenter.InstanceGroup&amp;quot;&lt;/span&gt;]$&amp;lt;/MonitoringClass&amp;gt; 
  &amp;lt;RelationshipClass&amp;gt;$MPElement[Name=&lt;span class="str"&gt;&amp;quot;SCIG!Microsoft.SystemCenter.InstanceGroupContainsEntities&amp;quot;&lt;/span&gt;]$&amp;lt;/RelationshipClass&amp;gt; 
  &amp;lt;IncludeList&amp;gt; 
    &amp;lt;MonitoringObjectId&amp;gt;$MPElement[Name=&lt;span class="str"&gt;'bwren.GroupDemo.SampleGroupLevel2'&lt;/span&gt;]$&amp;lt;/MonitoringObjectId&amp;gt; 
  &amp;lt;/IncludeList&amp;gt; 
&amp;lt;/MembershipRule&amp;gt;&lt;/pre&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Finally, we need to talk about empty groups since this is very common situation when programmatically creating groups.&amp;#160; You may automate the creation of a large group structure relying on users to add objects to these groups through the Operations Console once the management pack is loaded.&amp;#160; Empty groups have a very specific structure which is below.&lt;/p&gt;

&lt;pre class="csharpcode"&gt;    &amp;lt;MembershipRule Comment=&lt;span class="str"&gt;&amp;quot;EMPTY_RULE_8eadaced-59c8-4ebc-a4e4-b8428a374442&amp;quot;&lt;/span&gt;&amp;gt; 
      &amp;lt;MonitoringClass&amp;gt;$MPElement[Name=&lt;span class="str"&gt;&amp;quot;SC!Microsoft.SystemCenter.AllComputersGroup&amp;quot;&lt;/span&gt;]$&amp;lt;/MonitoringClass&amp;gt; 
      &amp;lt;RelationshipClass&amp;gt;$MPElement[Name=&lt;span class="str"&gt;&amp;quot;SCIG!Microsoft.SystemCenter.InstanceGroupContainsEntities&amp;quot;&lt;/span&gt;]$&amp;lt;/RelationshipClass&amp;gt; 
      &amp;lt;Expression&amp;gt; 
        &amp;lt;SimpleExpression&amp;gt; 
          &amp;lt;ValueExpression&amp;gt; 
            &amp;lt;Value&amp;gt;True&amp;lt;/Value&amp;gt; 
          &amp;lt;/ValueExpression&amp;gt; 
          &amp;lt;Operator&amp;gt;Equal&amp;lt;/Operator&amp;gt; 
          &amp;lt;ValueExpression&amp;gt; 
            &amp;lt;Value&amp;gt;False&amp;lt;/Value&amp;gt; 
          &amp;lt;/ValueExpression&amp;gt; 
        &amp;lt;/SimpleExpression&amp;gt; 
      &amp;lt;/Expression&amp;gt; 
    &amp;lt;/MembershipRule&amp;gt; &lt;br /&gt;&lt;/pre&gt;

&lt;p&gt;As you can see, the basic logic is to check if True equals False.&amp;#160; Since this will obviously never be a true statement, we have no objects that match the criteria.&amp;#160; The other thing you need though is the comment with that specific string on the MembershipRule tab.&amp;#160; There’s no real value in going into the background on that.&amp;#160; Just know that you need it.&amp;#160; If you don’t include it, the group will get created, but you’ll get a pretty ugly error when you try to modify the membership of that group from the Operations Console. &lt;/p&gt;

&lt;h2&gt;Management Pack Aliases &lt;/h2&gt;

&lt;p&gt;If you aren’t familiar with management pack aliases, they are separated from management object names with a ! in all the examples above.&amp;#160; An alias is required if you are referring to an object in another management pack.&amp;#160; The alias to that management pack must be in the References section of the management pack containing your group.&amp;#160; In the examples above, you can see the alias SCIG which refers to the System Center Instances Group management pack.&amp;#160; As such, the Reference section would need to contain the following entry.&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&amp;lt;Reference Alias=&lt;span class="str"&gt;&amp;quot;SCIG&amp;quot;&lt;/span&gt;&amp;gt; 
  &amp;lt;ID&amp;gt;Microsoft.SystemCenter.InstanceGroup.Library&amp;lt;/ID&amp;gt; 
  &amp;lt;Version&amp;gt;6.0.6278.0&amp;lt;/Version&amp;gt; 
  &amp;lt;PublicKeyToken&amp;gt;31bf3856ad364e35&amp;lt;/PublicKeyToken&amp;gt; 
&amp;lt;/Reference&amp;gt;&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;Your management pack might use a different alias for Microsoft.SystemCenter.InstanceGroup.Library.&amp;#160; I just created a new management pack with the Operations Console, and it used MicrosoftSystemCenterInstanceGroupLibrary6164070. Obviously, you will need to use whatever alias your management pack is using.&amp;#160; I have some code that will figure out what alias is being used for a particular management pack, but that will have to wait for a later post.&lt;/p&gt;

&lt;h2&gt;Creating the Group&lt;/h2&gt;

&lt;p&gt;Now that you know how to create the formula, you need the code to create the group.&amp;#160; We’re using the InsertCustomMonitoringObjectGroup method of the ManagementPack class.&amp;#160; We need to pass that a CustomMonitoringObjectGroup which is created with a group name, a group display name, and a formula.&amp;#160; The group name is created from a combination of a namespace and a name.&amp;#160; The namespace acts as the standard prefix for all objects in the management pack.&amp;#160; It will append that the the group name that we specify to build a complete name.&amp;#160; In the example below, I’m using a namespace of bwren.Groups and a group name of Gargantua.&amp;#160; The full name of the resulting group will be bwren.Groups.Gargantua.&lt;/p&gt;

&lt;p&gt;With all that explanation, I’ll let the following code speak for itself.&amp;#160; This example creates an empty group, but all you would need to do to create a different membership rule is to replace the $formula variable with one of the examples above.&lt;/p&gt;

&lt;pre class="csharpcode"&gt;$mpName = &lt;span class="str"&gt;'bwren.Groups'&lt;/span&gt; 
$namespace = &lt;span class="str"&gt;'bwren.groups'&lt;/span&gt; 
$groupName = &lt;span class="str"&gt;'gargantua'&lt;/span&gt; 
$groupDisplayName = &lt;span class="str"&gt;'Gargantua'&lt;/span&gt;


$formula =  &lt;span class="str"&gt;'&amp;lt;MembershipRule Comment=&amp;quot;EMPTY_RULE_8eadaced-59c8-4ebc-a4e4-b8428a374442&amp;quot;&amp;gt;'&lt;/span&gt; + ` 
            &lt;span class="str"&gt;'&amp;lt;MonitoringClass&amp;gt;$MPElement[Name=&amp;quot;SCIG!Microsoft.SystemCenter.InstanceGroup&amp;quot;]$&amp;lt;/MonitoringClass&amp;gt;'&lt;/span&gt; + ` 
            &lt;span class="str"&gt;'&amp;lt;RelationshipClass&amp;gt;$MPElement[Name=&amp;quot;SCIG!Microsoft.SystemCenter.InstanceGroupContainsEntities&amp;quot;]$&amp;lt;/RelationshipClass&amp;gt;'&lt;/span&gt; + ` 
            &lt;span class="str"&gt;'&amp;lt;Expression&amp;gt;'&lt;/span&gt; + ` 
            &lt;span class="str"&gt;'&amp;lt;SimpleExpression&amp;gt;'&lt;/span&gt; + ` 
            &lt;span class="str"&gt;'&amp;lt;ValueExpression&amp;gt;'&lt;/span&gt; + ` 
            &lt;span class="str"&gt;'&amp;lt;Value&amp;gt;True&amp;lt;/Value&amp;gt;'&lt;/span&gt; + ` 
            &lt;span class="str"&gt;'&amp;lt;/ValueExpression&amp;gt;'&lt;/span&gt; + ` 
            &lt;span class="str"&gt;'&amp;lt;Operator&amp;gt;Equal&amp;lt;/Operator&amp;gt;'&lt;/span&gt; + ` 
            &lt;span class="str"&gt;'&amp;lt;ValueExpression&amp;gt;'&lt;/span&gt; + ` 
            &lt;span class="str"&gt;'&amp;lt;Value&amp;gt;False&amp;lt;/Value&amp;gt;'&lt;/span&gt; + ` 
            &lt;span class="str"&gt;'&amp;lt;/ValueExpression&amp;gt;'&lt;/span&gt; + ` 
            &lt;span class="str"&gt;'&amp;lt;/SimpleExpression&amp;gt;'&lt;/span&gt; + ` 
            &lt;span class="str"&gt;'&amp;lt;/Expression&amp;gt;'&lt;/span&gt; + ` 
            &lt;span class="str"&gt;'&amp;lt;/MembershipRule&amp;gt;'&lt;/span&gt; 

$group = New-Object Microsoft.EnterpriseManagement.Monitoring.CustomMonitoringObjectGroup($namespace,$groupName,$groupDisplayName,$formula) 
$mp = Get-ManagementPack -name $mpName 
$mp.InsertCustomMonitoringObjectGroup($group)&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;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;img src="http://blogs.technet.com/aggbug.aspx?PostID=3155696" 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></item><item><title>One more MMS Follow Up</title><link>http://blogs.technet.com/brianwren/archive/2008/05/07/one-more-mms-follow-up.aspx</link><pubDate>Wed, 07 May 2008 19:26:00 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3051661</guid><dc:creator>Brian Wren</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.technet.com/brianwren/comments/3051661.aspx</comments><wfw:commentRss>http://blogs.technet.com/brianwren/commentrss.aspx?PostID=3051661</wfw:commentRss><description>&lt;P&gt;As I ran out of time in the MMS session, I quickly showed a script that listed all performance monitors and their thresholds.&amp;nbsp; This came from the &lt;A href="http://www.microsoft.com/downloads/details.aspx?FamilyId=DB3E6FB0-880E-4086-BDEF-1D45327F6A84&amp;amp;displaylang=en" mce_href="http://www.microsoft.com/downloads/details.aspx?FamilyId=DB3E6FB0-880E-4086-BDEF-1D45327F6A84&amp;amp;displaylang=en"&gt;SharePoint Portal Server Management Pack Guide&lt;/A&gt;.&amp;nbsp; The only change I made was to comment out the command to export the results to a csv so the information would come scrolling across the screen.&amp;nbsp; I attached the script with that small change to this post.&lt;/P&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3051661" width="1" height="1"&gt;</description><enclosure url="http://blogs.technet.com/brianwren/attachment/3051661.ashx" length="1628" 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></item><item><title>Monitoring Object Properties</title><link>http://blogs.technet.com/brianwren/archive/2008/05/03/monitoring-object-properties.aspx</link><pubDate>Sun, 04 May 2008 00:10:00 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3049392</guid><dc:creator>Brian Wren</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.technet.com/brianwren/comments/3049392.aspx</comments><wfw:commentRss>http://blogs.technet.com/brianwren/commentrss.aspx?PostID=3049392</wfw:commentRss><description>&lt;P&gt;There has been some question about how to get properties for monitoring objects with Command Shell.&amp;nbsp; I wanted to go into this in my MMS session last week, but I already ran out of time just trying to cram in all the topics I did cover.&amp;nbsp; Shouldn't be too tough to explain it here though.&lt;/P&gt;
&lt;P&gt;If you use Get-MonitoringObject, you get a common set of properties for all objects.&amp;nbsp; Kind of like the following:&lt;/P&gt;&lt;PRE class=csharpcode&gt;PS Monitoring:\OpsMgr01
&amp;gt;$mc = get-monitoringClass -name Microsoft.Windows.Computer
&amp;gt;$mc | get-monitoringObject | where {$_.name &lt;SPAN class=preproc&gt;-match&lt;/SPAN&gt; &lt;SPAN class=str&gt;'web01'&lt;/SPAN&gt;} 

Id               : 0844f543-762c-5800-794c-a72a1823ea96
PathName         : web01.greengargantua.com
DisplayName      : web01.greengargantua.com
ManagementMode   :
ManagementGroup  : gaira
HealthState      : Success
OperationalState : 

PS Monitoring:\OpsMgr01
&amp;gt;$mc = get-monitoringClass -name Microsoft.SQLServer.2005.Database &lt;BR&gt;&amp;gt;$mc | get-monitoringObject | where {$_.name &lt;SPAN class=preproc&gt;-match&lt;/SPAN&gt; &lt;SPAN class=str&gt;'blob'&lt;/SPAN&gt;} &lt;BR&gt; 

Id               : dfd4fd2b-6c7f-6c9c-a1cd-4d074613e3fd
PathName         : opsmgr01.greengargantua.com%003bMSSQLSERVER%003ablob
DisplayName      : blob
ManagementMode   :
ManagementGroup  : gaira
HealthState      : Success
OperationalState : 
&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;That example shows two objects that are completely different - a database and a computer - but we show an identical set of properties.&amp;nbsp; We know that there a bunch of properties unique to each of those classes, but where are they? 
&lt;P&gt;In order to display all properties for the object, you can use one of the Format CmdLets with * indicating you want all properties.&amp;nbsp; That results in the following:&amp;nbsp; &lt;PRE class=csharpcode&gt;PS Monitoring:\OpsMgr01
&amp;gt;$mc = get-monitoringClass -name Microsoft.SQLServer.2005.Database&lt;BR&gt;&amp;gt;$mc | get-monitoringObject | where {$_.name &lt;SPAN class=preproc&gt;-match&lt;/SPAN&gt; &lt;SPAN class=str&gt;'blob'&lt;/SPAN&gt;} | fl * 

PathName                                        : opsmgr01.bwren.com%003bMSSQLSERVER%003ablob
UniquePathName                                  : Microsoft.SQLServer.Database%003aopsmgr01.bwren.com%003bMSSQLSERVER%003bblob
[Microsoft.SQLServer.Database].DatabaseName     : blob
[Microsoft.SQLServer.Database].RecoveryModel    : FULL
[Microsoft.SQLServer.Database].DatabaseAutogrow : True
[Microsoft.SQLServer.Database].DatabaseSize     : 2
[Microsoft.SQLServer.Database].LogAutogrow      : True
[Microsoft.SQLServer.Database].Updateability    : READ_WRITE
[Microsoft.SQLServer.Database].UserAccess       : MULTI_USER
[Microsoft.SQLServer.Database].Collation        : SQL_Latin1_General_CP1_CI_AS
[Microsoft.SQLServer.Database].LogSize          : 1
[Microsoft.SQLServer.Database].Owner            : BWREN\Administrator
[System.Entity].DisplayName                     : blob
Name                                            : blob
Path                                            : opsmgr01.bwren.com;MSSQLSERVER
DisplayName                                     : blob
FullName                                        : Microsoft.SQLServer.Database:opsmgr01.bwren.com;MSSQLSERVER;blob
IsManaged                                       : True
LastModified                                    : 11/26/2007 7:07:20 AM
HealthState                                     : Success
StateLastModified                               : 5/1/2008 8:39:45 PM
IsAvailable                                     : True
AvailabilityLastModified                        : 5/3/2008 5:20:29 PM
InMaintenanceMode                               : False
MaintenanceModeLastModified                     : 5/1/2008 8:39:06 PM
MonitoringClassIds                              : {10c1c7f7-ba0f-5f9b-c74a-79a891170934, cae6be07-6483-361b-710f-c7612e29fa7b}
LeastDerivedNonAbstractMonitoringClassId        : 10c1c7f7-ba0f-5f9b-c74a-79a891170934
Id                                              : dfd4fd2b-6c7f-6c9c-a1cd-4d074613e3fd
ManagementGroup                                 : bwren
ManagementGroupId                               : 80342cfb-a3e1-aa59-7eac-cb5b5f167c38 
&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;The properties specific to the individual class are preceded with the name of the class they came from surrounded by brackets.&amp;nbsp; I'll explain the details of that later.&amp;nbsp; For now, just know that you have to specify the entire thing to retrieve the property value.&amp;nbsp; Since PowerShell sees those brackets as special characters, you need to surround the entire property name with quotes.&amp;nbsp; &lt;PRE class=csharpcode&gt;&amp;gt;$mc = get-monitoringClass -name Microsoft.SQLServer.2005.Database&lt;BR&gt;&amp;gt;$mo = $mc | get-monitoringObject | where {$_.name &lt;SPAN class=preproc&gt;-match&lt;/SPAN&gt; &lt;SPAN class=str&gt;'blob'&lt;/SPAN&gt;}&lt;BR&gt;&amp;gt;$mo."[Microsoft.SQLServer.Database].LogAutogrow"
&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;That syntax can actually get tricky, and I'll be honest that I haven't figured out how to get it working in all cases.&amp;nbsp; The other approach you can use is the Get-MonitoringObjectProperty CmdLet.&amp;nbsp; The name property from that CmdLet will be the simple name of the property.&amp;nbsp; &lt;PRE class=csharpcode&gt;&amp;gt;$mc = get-monitoringClass -name Microsoft.SQLServer.2005.Database &lt;BR&gt;&amp;gt;$mo = $mc | get-monitoringObject | where {$_.name &lt;SPAN class=preproc&gt;-match&lt;/SPAN&gt; &lt;SPAN class=str&gt;'blob'&lt;/SPAN&gt;} &lt;BR&gt;&amp;gt;$mo | get-monitoringObjectProperty | sort parentElement,name | ft parentElement,name,value 

ParentElement                         Name                      Value
-------------                         ----                      -----
Microsoft.SQLServer.Database          Collation                 SQL_Latin1_General_CP1_CI_AS
Microsoft.SQLServer.Database          DatabaseAutogrow          True
Microsoft.SQLServer.Database          DatabaseName              blob
Microsoft.SQLServer.Database          DatabaseSize              2
Microsoft.SQLServer.Database          LogAutogrow               True
Microsoft.SQLServer.Database          LogSize                   1
Microsoft.SQLServer.Database          Owner                     BWREN\Administrator
Microsoft.SQLServer.Database          RecoveryModel             FULL
Microsoft.SQLServer.Database          Updateability             READ_WRITE
Microsoft.SQLServer.Database          UserAccess                MULTI_USER
System.Entity                         DisplayName               blob

&lt;/PRE&gt;
&lt;P&gt;If you already know about the concept of base classes in OpsMgr, then you already know what that that ParentElement class is.&amp;nbsp; If not, let me provide a very brief description just so you at least have a little background information.If you want more details on this whole concept of class structures in OpsMgr, the &lt;A href="http://download.microsoft.com/download/7/4/d/74deff5e-449f-4a6b-91dd-ffbc117869a2/OM2007_AuthGuide.doc" mce_href="http://download.microsoft.com/download/7/4/d/74deff5e-449f-4a6b-91dd-ffbc117869a2/OM2007_AuthGuide.doc"&gt;Authoring Guide&lt;/A&gt; has complete documentation.&lt;/P&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;All classes in OpsMgr have a base class.&amp;nbsp; That base class may have a base class, and its base class may have a base class, etc.&amp;nbsp; All classes will eventually find their way up to System.Entity which is the only class with no base.&amp;nbsp; The object tree for the SQL 2005 Database class is shown below.&lt;/P&gt;
&lt;P align=center&gt;&lt;A href="http://blogs.technet.com/blogfiles/brianwren/WindowsLiveWriter/MonitoringObjectProperties_C7BC/image_6.png" mce_href="http://blogs.technet.com/blogfiles/brianwren/WindowsLiveWriter/MonitoringObjectProperties_C7BC/image_6.png"&gt;&lt;IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=210 alt=image src="http://blogs.technet.com/blogfiles/brianwren/WindowsLiveWriter/MonitoringObjectProperties_C7BC/image_thumb_2.png" width=451 border=0 mce_src="http://blogs.technet.com/blogfiles/brianwren/WindowsLiveWriter/MonitoringObjectProperties_C7BC/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;If a class has properties associated with it, then any classes that inherit from it (ie. they use that class as their base class) inherit its properties and any properties along the class tree.&amp;nbsp; There are no properties explicitly assigned to SQL 2005 Database.&amp;nbsp; Instead, those properties you see (Collation, DatabaseAutogroup, etc) are defined on the SQL Database class.&amp;nbsp; As you might imagine, SQL 2000 Database inherits from that same class so it inherits the same properties as SQL Database.&lt;/P&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;img src="http://blogs.technet.com/aggbug.aspx?PostID=3049392" 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></item><item><title>Setting Maintenance Mode from an Agent</title><link>http://blogs.technet.com/brianwren/archive/2008/05/01/setting-maintenance-mode-from-an-agent.aspx</link><pubDate>Fri, 02 May 2008 03:19:00 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3048346</guid><dc:creator>Brian Wren</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.technet.com/brianwren/comments/3048346.aspx</comments><wfw:commentRss>http://blogs.technet.com/brianwren/commentrss.aspx?PostID=3048346</wfw:commentRss><description>&lt;P&gt;My apologies that I forgot to talk about this in my MMS session earlier today.&amp;nbsp; I did mention it to a couple of people after the session.&amp;nbsp; &lt;A href="http://derekhar.blogspot.com/" mce_href="http://derekhar.blogspot.com/"&gt;Derek Harkin&lt;/A&gt; came up with an interesting method for initiating maintenance mode from an agent.&amp;nbsp; No OpsMgr client of any kind required - just a simple script for the user to execute.&amp;nbsp; No need to reiterate the details here, have a look at &lt;A href="http://derekhar.blogspot.com/2008/02/initiate-maintenance-mode-from-agent-no.html" mce_href="http://derekhar.blogspot.com/2008/02/initiate-maintenance-mode-from-agent-no.html"&gt;Derek's blog entry&lt;/A&gt;.&lt;/P&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3048346" 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></item><item><title>MMS Command Shell Presentation</title><link>http://blogs.technet.com/brianwren/archive/2008/03/11/mms-command-shell-presentation.aspx</link><pubDate>Tue, 11 Mar 2008 17:28:00 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:2988208</guid><dc:creator>Brian Wren</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.technet.com/brianwren/comments/2988208.aspx</comments><wfw:commentRss>http://blogs.technet.com/brianwren/commentrss.aspx?PostID=2988208</wfw:commentRss><description>&lt;P&gt;As promised, here are all the samples that I am showing in my MMS session on Command Shell.&amp;nbsp; There are also a several samples I'm planning on mentioning but won't have time to show.&amp;nbsp; Hope it's helpful.&lt;/P&gt;
&lt;P&gt;Given the length of the this, chances are pretty good that I have an error somewhere.&amp;nbsp; Please let me know if there's anything that doesn't work, if there's anything you think I forgot, or if you have any improvements to any of these scenarios.&amp;nbsp; &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;H1&gt;Management Groups&lt;/H1&gt;
&lt;P&gt;Add a management group connection:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P align=left&gt;&lt;FONT face="Courier New"&gt;&amp;gt; new-managementGroupConnection OpsMgr02&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P align=center mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Change your default management group connection:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P align=left&gt;&lt;FONT face="Courier New"&gt;&amp;gt; new-defaultManagementGroupConnection OpsMgr02 $true&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;View all current management group connections:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P align=left&gt;&lt;FONT face="Courier New"&gt;&amp;gt; get-ManagementGroupConnection&lt;/FONT&gt;&lt;/P&gt;
&lt;P align=left&gt;or&lt;/P&gt;
&lt;P align=left&gt;&lt;FONT face="Courier New"&gt;&amp;gt; cd \&lt;BR&gt;&amp;gt; dir&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;H1&gt;Management Packs&lt;/H1&gt;
&lt;P align=left&gt;Export a specific management pack (sealed or unsealed):&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P align=left&gt;&lt;FONT face="Courier New"&gt;&amp;gt; get-managementPack -name Microsoft.SQLServer.2005.Monitoring | export-managementPack -path c:\mp&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P align=left mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P align=left&gt;Export all management packs in a management group:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P align=left&gt;&lt;FONT face="Courier New"&gt;&amp;gt; get-managementPack | export-managementPack -path c:\mp &lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P align=left mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P align=left&gt;Install a management pack to multiple management groups:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P align=left&gt;&lt;FONT face="Courier New"&gt;&amp;gt; new-managementGroupConnection OpsMgr02&lt;BR&gt;&amp;gt; cd \&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&amp;gt; install-managementPack c:\mp\Contoso.MyManagementPack.mp &lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P align=left mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P align=left&gt;Export management pack from test environment, seal it,&amp;nbsp;and import to two production management groups:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;&amp;gt; get-managementPack -name bwren.MMS | export-managementPack -path c:\mp&lt;BR&gt;&amp;gt; MPSeal.exe&amp;nbsp; Contoso.MyManagementPack.xml /I c:\mp /Keyfile c:\keys\contosoKeyPair.snk&amp;nbsp; /Company "Contoso"&lt;BR&gt;&amp;gt; new-managementGroupConnection ggOpsMgr01.greenGargantua.com&lt;BR&gt;&amp;gt; cd \ggOpsMgr01.greenGargantua.com&lt;BR&gt;&amp;gt; install-managementPack c:\mp\bwren.mms.xml&lt;BR&gt;&amp;gt; cd \OpsMgr01.bwren.com&lt;BR&gt;&amp;gt; get-managementGroupConnection | where {$_.managementServerName -eq 'ggOpsMgr01.greenGargantua.com'} | remove-managementGroupConnection&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P align=left mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;H1&gt;&lt;/H1&gt;
&lt;H1&gt;Agents&lt;/H1&gt;
&lt;P&gt;Install an agent on a single computer:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;gt; $ms = get-managementServer | where {$_.name -eq 'OpsMgr02.GreenGargantua.com'}&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;BR&gt;&amp;gt; install-agentByName -name 'srv01' -managementServer $ms&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Install agents to a list of computers from a text file:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;FONT face="Courier New"&gt;&amp;gt; $ms = get-managementServer | where {$_.name -eq 'OpsMgr02.GreenGargantua.com'}&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;BR&gt;&amp;gt; gc c:\scripts\agents.txt | foreach {install-agentByName -name $_ -managementServer $ms}&lt;/FONT&gt;&lt;/BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Schedule install of agents to a list of computers from a text file.&amp;nbsp; &lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;Script: InstallAgents.ps1&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;param($file,$managementServer,$rmsServerName) &lt;/FONT&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;Add-PSSnapin "Microsoft.EnterpriseManagement.OperationsManager.Client";&lt;BR&gt;Set-Location "OperationsManagerMonitoring::";&lt;BR&gt;$mgConn = New-ManagementGroupConnection -connectionString:$rmsServerName&lt;BR&gt;Set-Location $rmsServerName &lt;/FONT&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;$ms = get-managementServer | where {$_.name -eq $managementServer}&lt;BR&gt;gc $file | foreach {install-agentByName -managementServer $ms -name $_}&lt;/FONT&gt;&lt;/P&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;Run from Task Scheduler:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe "c:\scripts\InstallAgents.ps1" -file:'c:\scripts\computers.txt' -managementServer:OpsMgr02 -rmsServerName:'OpsMgr01' &lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Discover all domain controllers and install an agent on each:&amp;nbsp; &lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;&amp;gt; $ms = get-managementServer | where {$_.name -eq 'OpsMgr02.GreenGargantua.com'}&lt;BR&gt;&amp;gt; $discoveryConfig = new-ldapQueryDiscoveryCriteria -domain contoso.com -ldapQuery "(primaryGroupID=516)"&lt;BR&gt;&amp;gt; $discoveryResult = start-discovery -managementServer $ms -windowsDiscoveryConfiguration $discoveryConfig&lt;BR&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&amp;gt; $installResult = install-agent -managementServer $ms -agentManagedComputer $discoveryResult.CustomMonitoringObjects&lt;BR&gt;&amp;gt; $installResult.MonitoringTaskResults&lt;/FONT&gt; &lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Display the proxy setting for all agents with a particular string in the computer name:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;gt; get-agent | where {$_.computerName -match 'dc'} | ft name,proxyingEnabled&lt;BR&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Enable the proxy setting for all agents with a particular string in the computer name:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;gt; $agents = get-agent | where {$_.computerName -match 'dc'} &lt;BR&gt;&amp;gt; $agents | foreach {$_.ProxyingEnabled = $true}&lt;BR&gt;&amp;gt; $agents | foreach {$_.ApplyChanges()}&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&lt;/P&gt;&lt;/FONT&gt;&lt;/BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;Move all agents on a subnet to a different management server: &lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;FONT face="Courier New" size=2&gt;&amp;gt; $ms = get-managementServer | where {$_.name -eq 'OpsMgr02.greenGargantua.com'}&lt;BR&gt;&amp;gt; $agents = get-agent | where {$_.IPAddress -match '10.2.*.*'} &lt;BR&gt;&amp;gt; $agents | set-managementServer -primaryManagementServer $ms&lt;/FONT&gt;&lt;BR&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;H1&gt;Security&lt;/H1&gt;
&lt;P align=left&gt;Get list of roles a user belongs to:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;FONT face="Courier New"&gt;&amp;gt; get-userRole | where {$_.users -match 'iggy'} | ft name&lt;/FONT&gt;&lt;/BLOCKQUOTE&gt;
&lt;P align=left mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P align=left&gt;Add list of users from a text file to a user role:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;Script: AddUsersFromFile.ps1&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&lt;/P&gt;param($file) 
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;$entries = import-csv -path $file&lt;BR&gt;foreach ($entry in $entries) {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $role = get-userRole | where {$_.name -eq $entry.role}&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; add-userToUserRole -userRole $role -user $entry.user&lt;BR&gt;} 
&lt;P&gt;Sample Text File: users.txt&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;role,user&lt;BR&gt;Marketing,contoso\iggy&lt;BR&gt;Marketing,contoso\johnny&lt;BR&gt;Finance,contoso\sid&lt;BR&gt;IT,contoso\trent&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;Running Script: 
&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;gt; c:\scripts\AddUsersFromFile -file c:\scripts\users.txt&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;H1&gt;Monitoring Classes and Objects&lt;/H1&gt;
&lt;BLOCKQUOTE&gt;&lt;/BLOCKQUOTE&gt;
&lt;P align=left&gt;List all monitoring classes:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;gt; get-monitoringClass&lt;FONT face="Courier New"&gt; | ft name&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P align=left&gt;List all SQL 2005 databases:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;gt; (get-monitoringClass&lt;FONT face="Courier New"&gt; -name Microsoft.SQLServer.2005.Database) | get-monitoringObject | ft name&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;OR&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;gt; (get-monitoringClass&lt;FONT face="Courier New"&gt; | where {$_.displayName -eq 'SQL 2005 DB'} | get-monitoringObject | ft name&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P align=left&gt;List all Windows computers and their IP addresses:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;&amp;gt; get-monitoringClass -name Microsoft.Windows.Computer | get-monitoringObject | foreach {$_."[Microsoft.Windows.Computer].IPAddress"}&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P align=left mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P align=left&gt;List all monitoring classes in the SQL Server 2005 Discovery management pack&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;&amp;gt; $mp = get-managementPack -name Microsoft.SQLServer.2005.Discovery&lt;BR&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&amp;gt; $mp | get-monitoringClass | ft name&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Display the proxy settings for all agents holding a particular class:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;gt; $mc = get-monitoringClass -name 'Microsoft.Windows.Server.AD.DomainControllerRole'&lt;BR&gt;&amp;gt; $&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;mos = $mc | get-monitoringObject &lt;BR&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&amp;gt; $mo | foreach {get-agent | where {$_.computerName -eq $mo.name}} | ft name,proxyingEnabled&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Enable the proxy settings for all agents holding a particular class:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;gt; $mc = get-monitoringClass -name 'Microsoft.Windows.Server.AD.DomainControllerRole'&lt;BR&gt;&amp;gt; $mos = $mc | get-monitoringObject &lt;BR&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&amp;gt; foreach ($mo in $mos) {&lt;BR&gt;&amp;nbsp;&amp;nbsp; $agent = get-agent | where {$_.computerName -eq $mo.displayName}&lt;BR&gt;&amp;nbsp;&amp;nbsp; $agent.proxyingEnabled = $true&lt;BR&gt;&amp;nbsp;&amp;nbsp; $agent.applyChanges()&lt;BR&gt;}&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;H1&gt;Maintenance Mode&lt;/H1&gt;
&lt;P align=left&gt;Set maintenance mode for a single object:&amp;nbsp; &lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;gt; $StartTime = (get-Date '4/1/2008 22:00').ToUniversalTime()&lt;BR&gt;&lt;FONT face="Courier New"&gt;&amp;gt; $EndTime = (get-Date '4/2/2008 2:00').ToUniversalTime()&lt;/FONT&gt;&lt;BR&gt;&amp;gt; $mc = get-monitoringClass -name Microsoft.SQLServer.2005.Database &lt;BR&gt;&lt;FONT face="Courier New"&gt;&amp;gt; $mo = get-monitoringObject -monitoringClass $mc | where {$_.name -eq 'MyDatabase'}&lt;BR&gt;&amp;gt; new-maintenanceWindow -monitoringObject $mo -startTime $StartTime -endTime $EndTime -reason PlannedOther -comment "Scheduled maintenance."&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT face="Courier New"&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/FONT&gt;
&lt;P align=left mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P align=left&gt;Set maintenance mode for an object and all of its contained objects:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;FONT face="Courier New"&gt;&amp;gt; $StartTime = (get-Date '4/1/2008 22:00').ToUniversalTime()&lt;BR&gt;&lt;FONT face="Courier New"&gt;&amp;gt; $EndTime = (get-Date '4/2/2008 2:00').ToUniversalTime()&lt;/FONT&gt;&lt;BR&gt;&amp;gt; $mc = get-monitoringClass -name Microsoft.Windows.Computer &lt;BR&gt;&lt;FONT face="Courier New"&gt;&amp;gt; $mo = get-monitoringObject -monitoringClass $mc | where {$_.name -eq 'srv01'}&lt;BR&gt;&amp;gt; $mo.ScheduleMaintenanceMode($StartTime,$EndTime,PlannedOther,"Nightly reboot.","Recursive")&lt;/FONT&gt;&lt;/FONT&gt;&lt;/BLOCKQUOTE&gt;
&lt;P align=left mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P align=left&gt;Schedule maintenance mode for all computers in a group (uses &lt;A href="http://blogs.msdn.com/boris_yanushpolsky/archive/2008/03/04/one-more-maintenance-mode-script.aspx" mce_href="http://blogs.msdn.com/boris_yanushpolsky/archive/2008/03/04/one-more-maintenance-mode-script.aspx"&gt;GroupMM.ps1&lt;/A&gt;):&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;FONT face="Courier New"&gt;&amp;gt; C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe "c:\scripts\GroupMM.ps1" -groupName:'Nightly Reboots' -hours:2 -rmsServerName:'OpsMgr01' -startMM:$true&lt;/FONT&gt;&lt;/BLOCKQUOTE&gt;
&lt;P align=left mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P align=left&gt;View maintenance mode history for an object:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;gt; $mc = get-monitoringClass -name Microsoft.Windows.Computer&lt;BR&gt;&lt;FONT face="Courier New"&gt;&amp;gt; $mo = get-monitoringObject -monitoringClass $mc | where {$_.name -eq 'srv01'}&lt;BR&gt;&amp;gt; $mo | get-maintenanceWindow -history&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;H1&gt;Tasks&lt;/H1&gt;
&lt;P&gt;Run task to enable audit collection on all agents: &lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;&amp;gt; $task = get-task | where {$_.name -eq 'Microsoft.SystemCenter.EnableAuditCollectionService'}&lt;BR&gt;&amp;gt; $mc = get-monitoringClass | where {$_.name -eq 'Microsoft.SystemCenter.HealthService'}&lt;BR&gt;&amp;gt; $mc | get-monitoringObject | foreach {start-task -task $task -targetMonitoringObject $_}&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;H1&gt;Data&lt;/H1&gt;
&lt;P align=left&gt;View all unresolved alerts:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P align=left&gt;&lt;FONT face="Courier New"&gt;&amp;gt; get-alert -criteria "ResolutionState &amp;lt;&amp;gt; 255"&lt;/FONT&gt; &lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P align=left mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P align=left&gt;View all alerts grouped by severity and name&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P align=left&gt;&lt;FONT face="Courier New"&gt;&amp;gt; get-alert -criteria "ResolutionState &amp;lt;&amp;gt; 255" | sort severity,name | group severity,name&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P align=left mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P align=left&gt;View alerts from a particular rule group by managed object:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P align=left&gt;&lt;FONT face="Courier New" size=2&gt;&amp;gt; get-alert -criteria "ResolutionState &amp;lt;&amp;gt; 255" | where {$_.name -match 'Script or Executable Failed to run'} | group monitoringObjectDisplayName&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P align=left mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P align=left&gt;Change resolution state of alerts from a particular rule group by managed object:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P align=left&gt;&lt;FONT face="Courier New" size=2&gt;&amp;gt; get-alert -criteria "ResolutionState &amp;lt;&amp;gt; 255" | where {$_.name -match 'Script or Executable Failed to run'} | group monitoringObjectDisplayName | foreach {&lt;BR&gt;&amp;gt;&amp;gt; $_.ResolutionState = 50&lt;BR&gt;&amp;gt;&amp;gt; $_.update("Comment")&lt;BR&gt;&amp;gt;&amp;gt;}&lt;BR&gt;&amp;gt;&amp;gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Resolve all alerts generated by rules as opposed to monitors:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P align=left&gt;&lt;FONT face="Courier New"&gt;&amp;gt; get-alert -criteria "ResolutionState &amp;lt;&amp;gt; 255 and IsMonitorAlert = 'False'" | resolve-Alert&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P align=left&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P align=left&gt;Reset health for a monitor called "Manual monitor" on all objects of the class "Contoso.MyCustomClass" currently in an Error state.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P align=left&gt;&lt;FONT face="Courier New"&gt;&amp;gt; $mon = get-monitor | where {$_.displayName -eq 'Manual monitor'}&lt;BR&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&amp;gt; $mc = get-monitoringClass -name Contoso.MyCustomClass&lt;BR&gt;&amp;gt; $mc | get-monitoringObject | where {$_.HealthState -eq 'Error'} | foreach {$_.ResetMonitoringState($mon)}&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;H1&gt;Performance Data&lt;/H1&gt;
&lt;P&gt;Extract processor utilization data for all computers for the month of March 2008 to a comma delimited file.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P align=left&gt;&lt;FONT face="Courier New"&gt;&amp;gt; $startTime = get-date '3/1/2008'&lt;BR&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&amp;gt; $endTime = get-date '3/31/2008'&lt;BR&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&amp;gt; $pc = get-performanceCounter -criteria: "ObjectName='Processor' and CounterName='% Processor Time' and MonitoringObjectPath='web02.bwren.com'"&lt;BR&gt;&lt;FONT face="Courier New"&gt;&amp;gt; get-performanceCounterValue -startTime $startTime -endTime $endTime -performanceCounter $pc | export-csv c:\scripts\mom\perf.csv&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P align=left&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;H1&gt;&lt;FONT face="Courier New" size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/H1&gt;
&lt;H1&gt;Management Pack Elements&lt;/H1&gt;
&lt;P align=left&gt;List all rules by management pack:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P align=left&gt;&lt;FONT face="Courier New"&gt;&amp;gt; get-rule | select @{name="MP";expression={foreach-Object {$_.GetManagementPack().DisplayName}}},DisplayName | sort mp,displayName &lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P align=left mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P align=left&gt;List all monitors in a specific management pack:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P align=left&gt;&lt;FONT face="Courier New"&gt;&amp;gt; (get-managementPack -name Microsoft.SQLServer.2005.Monitoring) | get-monitor | sort displayName | ft displayName&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P align=left&gt;List all disabled discoveries:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P align=left&gt;&lt;FONT face="Courier New"&gt;&amp;gt; get-discovery | where {$_.enabled -eq 'false'} | ft displayName&lt;/FONT&gt; &lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P align=left mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P align=left&gt;View the display name, category, and enabled status of all performance collection rules in the SQL Server 2005 Monitoring management pack:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;gt; get-rule -managementPack $mp | where {$_.category -eq 'PerformanceCollection'} | ft displayName,category,enabled&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=2988208" 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></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>Great Minds Think Alike</title><link>http://blogs.technet.com/brianwren/archive/2008/03/04/great-minds-think-alike.aspx</link><pubDate>Wed, 05 Mar 2008 07:46:00 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:2962642</guid><dc:creator>Brian Wren</dc:creator><slash:comments>8</slash:comments><comments>http://blogs.technet.com/brianwren/comments/2962642.aspx</comments><wfw:commentRss>http://blogs.technet.com/brianwren/commentrss.aspx?PostID=2962642</wfw:commentRss><description>&lt;p&gt;I just got done with my previous post on setting maintenance mode for a group of objects, and I happened to check &lt;a href="http://blogs.msdn.com/boris_yanushpolsky/"&gt;Boris Yanushpolsky's blog&lt;/a&gt;.&amp;nbsp;&amp;nbsp; Bori's blog is an outstanding reference for various Command Shell scripts, and I have to give him credit for helping me come up to speed on several concepts.&amp;nbsp; Turns out just tonight put up a script for....yep, you guessed it....&lt;a href="http://blogs.msdn.com/boris_yanushpolsky/archive/2008/03/04/one-more-maintenance-mode-script.aspx"&gt;setting maintenance mode on a group of objects&lt;/a&gt;. &lt;/p&gt; &lt;p&gt;As it turns out, I spent more time getting the script to run in a management pack, using overrides, etc.&amp;nbsp; The script that Boris did is more complex than the one I did by putting computers into maintenance mode along with their health service.&amp;nbsp; If that one fits your requirements better, than it should take all that much effort to move it into my sample management pack.&amp;nbsp; Just a matter of pasting the script code into my write action and swapping around some script arguments.&lt;/p&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=2962642" 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></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>4</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></channel></rss>