Answered by:
A problem with criteria option of Get-Alert cmdlet

Question
-
The criteria parameter of get-alert cmdlet seems to treat 'greater' operator as 'greater or equal'. Here's an example:
>get-alert -criteria "TimeRaised > '2/15/2010 4:49:47 AM'" | Select-Object TimeRaised
TimeRaised
----------
2/15/2010 4:50:47 AM
2/15/2010 4:49:47 AM
Is this an expected behavior?
How should I request alerts that were raised after a certain time, but not inclusively?Monday, February 15, 2010 5:02 AM
Answers
-
I think this is correct behaviour.
The selection is '2/15/2010 4:49:47 AM', which will be translated to: '2/15/2010 4:49:47.000 AM'
When the time raised is 2/15/2010 4:49:47.365 AM, the output is correct.
So alerts greater than 4:49:47.000 are shown. If you need data from 4:49:48.000, you could use "TimeRaised >= '2/15/2010 4:49:48 AM'".
This should result in the time raised of 4:49:47 not being displayed.
Regards,
Marc Klaver
http://jama00.wordpress.com/- Proposed as answer by Marco Shaw Wednesday, February 17, 2010 9:54 PM
- Marked as answer by Budchee Wednesday, February 17, 2010 10:20 PM
Wednesday, February 17, 2010 8:04 AM
All replies
-
Interesting... It should be "greater than" according to THIS .
You may want to file this as a big and use +1 seconds as a workaround to get the greater than value.- Proposed as answer by Marco Shaw Monday, February 15, 2010 5:02 PM
- Unproposed as answer by Marco Shaw Wednesday, February 17, 2010 9:58 PM
Monday, February 15, 2010 5:02 PM -
Thank you,
But I guess adding a second might cause alerts possibly raised between 47th and 48th seconds to be ignored?
I'd like to try getting alerts using C# to see if that can solve my problem. Is it possible?
I couldn't find examples of using the SDK to get alerts in .Net..
Well, actually there is one here: http://msdn.microsoft.com/en-us/library/bb437502.aspx
but I don't want to resolve alerts been read, as I'm interested in monitoring both resolved and unresolved alerts over time.Tuesday, February 16, 2010 7:50 PM -
I think this is correct behaviour.
The selection is '2/15/2010 4:49:47 AM', which will be translated to: '2/15/2010 4:49:47.000 AM'
When the time raised is 2/15/2010 4:49:47.365 AM, the output is correct.
So alerts greater than 4:49:47.000 are shown. If you need data from 4:49:48.000, you could use "TimeRaised >= '2/15/2010 4:49:48 AM'".
This should result in the time raised of 4:49:47 not being displayed.
Regards,
Marc Klaver
http://jama00.wordpress.com/- Proposed as answer by Marco Shaw Wednesday, February 17, 2010 9:54 PM
- Marked as answer by Budchee Wednesday, February 17, 2010 10:20 PM
Wednesday, February 17, 2010 8:04 AM