Looking at OpsMgr2007 Alert trend with Command Shell
It's friday night, I am quite tired and I can't be asked of writing a long post. But I have not written much all week, not even updated my Twitter, and now I want to finish the week with at least some goodies. So this is the turn of a couple of Powershell commands/snippets/scripts that will count alerts and events generated each day: this information could help you understand the trends of events and alerts over time in a Management Group. It is nothing fancy at all, but they can still be useful to someone out there. In the past (MOM 2005) I used to gather this kind of information with SQL Queries against the operations database. But now, with Powershell, everything is exposed as objects and it is much easier to get information without really getting your hands dirty with the database :-)
#Number of Alerts per day
$alerttimes = Get-Alert | Select-Object TimeRaised
$array=@()
foreach ($datetime in $alerttimes){
$array += $datetime.timeraised.date
}
$array | Group-Object Date
#Number of Events per day
$eventtimes = Get-Event | Select-Object TimeGenerated
$array=@()
foreach ($datetime in $eventtimes){
$array += $datetime.timegenerated.date
}
$array | Group-Object Date
Beware that these "queries" might take a long time to execute (especially the events one) depending on the amount of data and your retention policy.
This is of course just scratching the surface of the amount of amazing things you can do with Powershell in Operations Manager 2007. For this kind of information you might want to keep an eye on the official "System Center Operations Manager Command Shell" blog: https://blogs.msdn.com/scshell/