我想创建 PowerShell 脚本来覆盖我的监视器和规则的某些参数。我使用了下面的代码,但我有一些错误。我想覆盖未启用的可覆盖参数或其他内容。我该怎么做?
$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()
错误:
错误1:异常设置“属性”:“无法将值“WarningThreshold”转换为
键入“Microsoft.EnterpriseManagement.Configuration.ManagementPackMonitorProperty”。
错误:“无法将标识符名称 WarningThreshold 与有效的枚举器匹配
姓名。指定以下枚举器名称之一并重试:已启用,
TraceEnabled, 算法, AlgorithmPercentage, DefaultState, GenerateAlert,
AutoResolve、AlertPriority、AlertOnState、AlertSeverity、AlertMessage、
警报参数 1、警报参数 2、警报参数 3、警报参数 4、
警报参数 5、警报参数 6、警报参数 7、警报参数 8、
AlertParameter9、AlertParameter10、MemberInMaintenance、MemberUnavailable、
IgnoreMemberInMaintenance, IgnoreMemberUnavailable""
在行:1 字符:2
+ $override.Property = $参数名
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], SetValueInvocationException
+fullyQualifiedErrorId : ExceptionWhenSetting
error2:使用“0”参数调用“AcceptChanges”的异常:“数据库错误。
MPInfra_p_ManagementPackInstall 失败并出现异常:无法验证项目:
测试规则1"
在行:193 字符:1
+ $MP.AcceptChanges()
+ ~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ManagementPackException