Operations Manager Command Shell Main Menu
Welcome to TechNet Blogs Sign in | Join | Help
Count all alerts, group by date

Count all alerts, group by date

$array = @();foreach ($date in Get-Alert | foreach-object {$_.get_TimeRaised().ToLocalTime().toShortDateString()}) {$array += $date};$array | Group-Object | select-object count,@{name="Date";expression={foreach-object {$_.name}}} | sort-object date –desc

main menu

Posted: Thursday, March 19, 2009 7:52 PM by jtalmquist

Comments

dmuscett said:

More or less the same as here

http://www.muscetta.com/2008/01/25/looking-at-opsmgr2007-alert-trend-with-command-shell/

Only issue with this approach (both mine and yours) is that it is painfully SLOW on big deployments. The SQL Queries on Kevin's blog are much better for performance :-)

# April 13, 2009 4:30 PM

jtalmquist said:

Thanks for the comment, Daniele.

One major difference in my script is it performs a Date-Time conversion.  Performing this DT conversion ensures accuracy in the results.  See more on that here.

Command Shell: Be careful with Date-Time criteria and calculations

As far as performance, this is true.  But the Command Shell is another option for those that do not have permissions to query SQL directly.

-Jonathan

# April 13, 2009 8:51 PM

dmuscett said:

I wrote that a long time ago (waaaay before blogging it). And yes, you are right: I did not take into account time zones, as I was testing that it italy, which is GMT+1... If your management group does not span multiple countries, you should be nearly alright :-)

# April 25, 2009 12:32 PM

jtalmquist said:

If you are in any time zone other than GMT and you do not do a Date-Time conversion, the results will be inaccurate, regardless of how many MG's you have and which time zones they span.

You can see this proven by changing the time zone on your workstation and running the script in this post.  Then, run the script in your post.  The results will be different.

btw - I think I borrowed the framework for this one from your post. :-)

# April 25, 2009 1:02 PM
Leave a Comment

(required) 

(required) 

(optional)

(required) 

  
Enter Code Here: Required

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Page view tracker