0

I want to create PowerShell scripts to override some parameter of my monitor and rule. I used the below code, but I have some errors. I want override my overidable parameter not enabled or something else. How can I doe this?

$mps = Get-SCOMManagementPack | ? {$_.Name -like "test"}
$overrideMp = Get-SCOMManagementPack -DisplayName "Overrides"

$overridename = "testmonitor.Overrides" 

$monitor = 'testmonitor'
$override = New-Object Microsoft.EnterpriseManagement.Configuration.ManagementPackMonitorPropertyOverride($overrideMp,$overridename)
$override.Monitor = $monitor

$override.Property = 'WarningThreshold'
$override.Value = 80
$override.DisplayName = "Overrides"

$overrideMp.Verify()
$overrideMp.AcceptChanges()

Errors:

error1: Exception setting "Property": "Cannot convert value "WarningThreshold" to
type "Microsoft.EnterpriseManagement.Configuration.ManagementPackMonitorProperty".
Error: "Unable to match the identifier name WarningThreshold to a valid enumerator
name.  Specify one of the following enumerator names and try again: Enabled,
TraceEnabled, Algorithm, AlgorithmPercentage, DefaultState, GenerateAlert,
AutoResolve, AlertPriority, AlertOnState, AlertSeverity, AlertMessage,
AlertParameter1, AlertParameter2, AlertParameter3, AlertParameter4,
AlertParameter5, AlertParameter6, AlertParameter7, AlertParameter8,
AlertParameter9, AlertParameter10, MemberInMaintenance, MemberUnavailable,
IgnoreMemberInMaintenance, IgnoreMemberUnavailable""
At line:1 char:2
+  $override.Property = $parametername
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], SetValueInvocationException
    + FullyQualifiedErrorId : ExceptionWhenSetting
error2 : Exception calling "AcceptChanges" with "0" argument(s): "Database error.
MPInfra_p_ManagementPackInstall failed with exception: Failed to validate item:
testrule1"
At line:193 char:1
+ $MP.AcceptChanges()
+ ~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ManagementPackException
Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
B.Z
  • 61
  • 1
  • 8

3 Answers3

0

The error message looks rather clear to me. There is no property WarningThreshold in the ManagementPackMonitorProperty enumeration. I don't have much experience with SCOM, but you probably need to override the property AlertOnState for monitors where the property AlertSeverity has the value Warning.

Try something along the lines of this:

$mps | Get-SCOMMonitor | Where-Object {
  # (other selection criteria) -and
  $_.AlertSettings.AlertSeverity -eq 'Warning'
} | ForEach-Object {
  $ctx = Get-SCOMClass -Id $_.Target.Id
  # ...
  $override = New-Object ...
  $override.Monitor = $_
  $override.Property = 'AlertOnState'
  $override.Value = 80
  $override.Context = $ctx
  # ...
}

Code adopted from here (probably the same place where you found it). Not sure if this works, though. Like I said, I have very little experience with SCOM, and I don't have a SCOM server available for testing.

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
0

I'll try to debug it tomorrow in the office.

BTW, there is a third-party tool for override management called MPTuner: http://mpwiki.viacode.com/default.aspx?g=mptuner It's free so you should try.

Roman.

0

It's quite confusing, but there are two different type of overrides for each workflow type. For a monitor there are:

MonitorPropertyOverride
MonitorConfigurationOverride

You are using the first one, wgich is for standard parameters only, like Enabled, for example. For any custom parameters use Configuration Override.

Max
  • 751
  • 6
  • 10