JAMA00

SCOM 2007 R2

Setting an override on a rule with PowerShell (OpsMgr snapin part 2)

Posted by MarcKlaver on March 31, 2010

I finished the works for two cmdlets now. The result can be downloaded at this location. In the last few days I learned a lot about PowerShell programming and the SCOM SDK 🙂 One of the results is a rename of the cmdlets and the use of the WriteVerbose and WriteObject methods.

The next two cmdlets are now available in the download:

  • Get-RuleParameter – This cmdlet shows you the name of the overrideable parameters of a rule, so you don’t have to dive into the .xml files as shown in part 1.
  • Set-RuleOverride – This cmdlet will set an override on a rule.

I hope the help file is sufficient to get you to the first use of the cmdlets. In my next post I will create examples on how to use these two cmdlets.

The following cmdlets are still in planning:

  • Get-MonitorParameter
  • Set-MonitorOverride

These cmdlets will not be created:

  • Get-ObjectId – The Get-MonitoringObject cmdlet from Microsoft can be used to retrieve the object id.
  • Enable-Monitor – This will be part of the Set-MonitorOverride cmdlet.
  • Disable-Monitor  – This will be part of the Set-MonitorOverride cmdlet.
  • Enable-Rule – This is now part of the Set-RuleOverride cmdlet
  • Disable-Rule – This is now part of the Set-RuleOverride cmdlet
Advertisements

3 Responses to “Setting an override on a rule with PowerShell (OpsMgr snapin part 2)”

  1. Pixel said

    No matter how i try to run this, it doesnt work.
    Example:
    set-ruleoverride -RootManagementServer “scomil1srv” -ManagementPack $mp -ClassCriteria DisplayName=”Exchange 2007 Hub Transport Role” -RuleCriteria “DisplayName=’The AD RMS

    Prelicensing agent failed to retrieve a license because recipient account(s) where not configured properly. Contact the AD RMS administrator.’” -Parameter “Severity” -Value 2

    -Target “28e02b23-6d72-0372-cec4-ab585c2b3991”

    or:

    $mp = get-managementpack |?{$_.Name -like “*exchange*monitoring*hub*”};
    $mp2 = get-managementpack |?{$_.Name -like “*rainbow*”};
    $Name = “The AD RMS Prelicensing agent failed to retrieve a license because recipient account(s) where not configured properly. Contact the AD RMS administrator.”
    $rule = get-rule -ManagementPack $mp |?{$_.DisplayName -eq $Name}
    $class = $rule.target
    $target = “28e02b23-6d72-0372-cec4-ab585c2b3991”

    set-ruleoverride -rootmanagementserver “scomil1srv” -managementpack $mp2 -classcriteria $rule.target -rulecriteria $rule -parameter “Severity” -value “2” -Target $target

    —————

    I GET:
    Microsoft.EnterpriseManagement.Common.InvalidCriteriaException: The criteria used fo
    r query has an invalid character or invalid keyword. The following parse error was r
    eturned: Parse error before 2007 —> Microsoft.EnterpriseManagement.Common.QueryGra
    mmarException: Parse error before 2007
    at Microsoft.EnterpriseManagement.Mom.QueryGrammar.QueryGrammarYaccClass.error(In
    t32 q_state, SSLexLexeme q_look)
    at Microsoft.EnterpriseManagement.Mom.QueryGrammar.SSVParseLib.SSYacc.doError()
    at Microsoft.EnterpriseManagement.Mom.QueryGrammar.SSVParseLib.SSYacc.parse()
    at Microsoft.EnterpriseManagement.Mom.QueryGrammar.QueryGrammarParser.GetCriteria
    Xml(String query)
    at Microsoft.EnterpriseManagement.Common.QueryCriteria.GetParseTree(String criter
    ia)
    — End of inner exception stack trace —
    at Microsoft.EnterpriseManagement.Common.QueryCriteria.GetParseTree(String criter
    ia)
    at Microsoft.EnterpriseManagement.Common.QueryCriteria.ParseCriteria(MonitoringCl
    ass monitoringClass, Boolean validateProperties)
    at Microsoft.EnterpriseManagement.Configuration.MonitoringClassCriteria..ctor(Str
    ing criteria)
    at mkrOpsMgr.SetRuleOverride.ProcessRecord()

    • MarcKlaver said

      If this is exactly as you have entered this, you should replace DisplayName=”Exchange 2007 Hub Transport Role” with “DisplayName=’Exchange 2007 Hub Transport Role’”

      Note the double and single quotes!
      You can also see this back in the error message: “Microsoft.EnterpriseManagement.Common.QueryGra
      mmarException: Parse error before 2007”

      Which means the parser gets confused by the space after Exchange 🙂

      And don’t forget this is for rules only. Monitors can not be set with this cmdlet, that must be done with the Set-MonitorOverride cmdlet (build in progress).

  2. […] Posted by MarcKlaver on May 12, 2010 A few examples on how to use the two cmdlets. […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: