param($sourceId,$managedEntityId,$computerName,$RESTService) $api= New-Object -ComObject 'MOM.ScriptAPI' $discoveryData=$api.CreateDiscoveryData(0,$sourceId,$managedEntityId) $proxy = Invoke-RestMethod -Uri $RESTService foreach($subFolder in $proxy.ArrayOfResources.Resources) { $instance=$discoveryData.CreateClassInstance("$MPElement[Name='SystemPulseKS.RestService.Resources']$") $instance.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$",$computerName) $instance.AddProperty("$MPElement[Name='SystemPulseKS.RestService.Resources']/ResourceName$",$subFolder.ResName) $instance.AddProperty("$MPElement[Name='SystemPulseKS.RestService.Resources']/ResGroup$",$subFolder.ResGroup) $discoveryData.AddInstance($instance) } #$api.Return($discoveryData) $discoveryDatahere is my powershell discovery script,it is running like a charm but how can I target those instances of class SystemPulseKS.RestService.Resources,So that I can add some monitoring data to those instances like monitors rule
From the SCOM console, you can select your class when you create a new rule or monitor (but you need to save this new rule/monitor to the same MP as the discovery, if it's unsealed).
From a text editor, just put Target="My.Discovered.Class" on your monitor/rule definition, for example
<UnitMonitor ID="My.Test.Monitor" Accessibility="Public" Enabled="true" Target="My.Discovered.Class" ParentMonitorID="Health!System.Health.AvailabilityState" Remotable="true"
Priority="Normal" TypeID="Windows!Microsoft.Windows.CheckNTServiceStateMonitorType" ConfirmDelivery="false">
< blah blah blah />
</UnitMonitor>