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
Comments
Anonymous
January 01, 2003
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 :-)Anonymous
January 01, 2003
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. :-)Anonymous
January 01, 2003
The comment has been removedAnonymous
January 01, 2003
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