【问题标题】:SCOM: recalculatemonitoringstate() issuesSCOM:重新计算监控状态()问题
【发布时间】:2017-08-09 10:20:44
【问题描述】:

脚本有问题,尝试通过 powershell 脚本重新计算 SCOM 中的信息。重新计算时遇到问题。

#imput parameters
Param(
[Parameter(Mandatory=$False)]
[string[]]$computerName
)
Import-Module OperationsManager
#Main SCOM server var
$computerName = "SCOMserver"
#Connect to the SCOM-Mgmt Server
New-SCOMManagementGroupConnection -ComputerName $computerName

#Get all the SCOMalert filtered queue warning state 
$alerts = Get-SCOMalert -ComputerName $computerName | Where-Object {$_.Owner -eq “user01” -and $_.ResolutionState -eq “0” -and $_.IsMonitorAlert -eq $true} 
Foreach ($ActiveMonitor in $alerts)
{
    $ActiveMonitor.recalculatemonitoringstate() | Test-SCOMMonitoringTaskResultForError
}

我得到的错误: 方法调用失败,因为 [Microsoft.EnterpriseManagement.Monitoring.MonitoringAlert] 不包含名为“recalculatemonitoringstate”的方法。

【问题讨论】:

    标签: windows powershell scom


    【解决方案1】:

    当你遇到这样的错误时,值得用谷歌搜索。

    在这种情况下,它正确地通知您您正在尝试调用该对象没有的方法 (RecalculateMonitoringState())。查看the MonitortingAlert class documentation

    这个类是相关的,因为你使用的是Get-SCOMAlert,它返回了一个这种类型的对象(在变量$alerts中)

    RecalculateMonitoringState() 方法是the MonitoringObject class 的一部分,因此您很可能在使用Get-SCOMMonitor

    【讨论】:

    • 您好,感谢您的回复。 (我在powershell中有点慢)从你的回答中我了解到,如果我找到了一些限制这两个Get-SCOMMonitor和Get-SCOMalert的东西,比如示例ID,并且可以将Get-SCOMalert ID中的数据grep到变量中并循环它在 Get-SCOMMonitor 中重新计算。 (除了我在谷歌搜索,但很难然后你不确定你想找到什么)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-02-07
    • 2016-06-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-13
    • 1970-01-01
    相关资源
    最近更新 更多