Hi,
I need to create a poweshell script that disable a monitor for a given host.
With the Disable-SCOMMonitor, I managed to disable it for a class, not an individual host. It looks feasable since you can disable it for a specific host of a class in the console.
So far I've got:
$Host = Read-Host "Enter computer name"
$MonitorName = "Total CPU Utilization Percentage"
$Monitors=Get-SCOMMonitor -ComputerName $strComputerName | where {$_.DisplayName -eq $MonitorName}
$MP = Get-SCOMManagementPack -DisplayName "BMA - Override - Orchestrator_Generated" | where {$_.Sealed -eq $False}
foreach ($Monitor in $Monitors) {
$Instance3 = Get-SCOMclass -name $Monitor.target.identifier.path | Get-SCOMClassInstance | where {$_.Path -eq $Host}
Disable-SCOMMonitor -Instance $Instance3 -ManagementPack $MP -Monitor $Monitor -Enforce
}
This does not return any error (besides when $Instance3 is empty, but that's an easy fix), but does not disable the monitor either...
I would appreciate some help to get that working :)
Thank you !