Quantcast
Channel: TechNet Blogs
Viewing all articles
Browse latest Browse all 34890

Getting Monitor State Change Events via PowerShell

$
0
0

 

image

 

This is a script example on how to get statechangeevents from monitor context using PowerShell.  This example uses a URL transaction monitor, but you can change this to any class/classinstance.

 

#Set arrays to empty $Monitor = @() $MonitorColl = @() $States = @() #Get Web Transaction URL Class $URLClass = Get-SCOMClass -Name 'Microsoft.SystemCenter.WebApplication.Perspective' #Get an array of matching specific instances of URL Class $URLInstances = $URLClass | Get-SCOMClassInstance | where {$_.displayname -eq "Bing URL Transaction"} #Loop through each URL instance ForEach ($UrlTest in $URLInstances) { #Set the monitor collection to empty and create the collection to contain monitors $MonitorColl = @() $MonitorColl = New-Object "System.Collections.Generic.List[Microsoft.EnterpriseManagement.Configuration.ManagementPackMonitor]" #Get specific monitors matching a displayname for this instance of URLtest ONLY $Monitor = Get-SCOMMonitor -Instance $UrlTest -Recurse | where {$_.DisplayName -eq "Content Match"} #Add this monitor to a collection $MonitorColl.Add($Monitor) #Get the state associated with this specific monitor $State=$UrlTest.getmonitoringstates($MonitorColl) #Add each state found in the loop to an array to be used later $States += $State } #get any statechangeevents for each item in the array $States[0].getmonitoringstatechangeevents() $States[1].getmonitoringstatechangeevents()

Viewing all articles
Browse latest Browse all 34890

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>