SCOM:recalculatemonitoringstate()问题

时间:2017-08-09 10:20:44

标签: windows powershell scom

脚本有问题,尝试通过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'。

的方法。

1 个答案:

答案 0 :(得分:1)

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

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

此类是相关的,因为您正在使用Get-SCOMAlert返回此类型的对象(在变量$alerts中)

RecalculateMonitoringState()方法是the MonitoringObject class的一部分,因此很可能是Get-SCOMMonitor之后。