I am trying to get alarms from a selected camera group. My current script is below. As you can see it will need to be changed everytime we change camera groups/source names. I am not sure where I need to go from here to be able to get this. At this point it seems like I am trying to push PStools way past its limits.
import-module MilestonePSTools
connect-managementserver -force -AcceptEula -ShowDialog
$c1 = New-AlarmCondition -Operator GreaterThan -Target Timestamp -Value (Get-Date).Date.AddDays(-7).ToUniversalTime()
$c2 = New-AlarmCondition -Target Timestamp -Operator GreaterThan -Value (Get-Date).Date.ToUniversalTime()
$c3 = New-AlarmCondition -Target Type -Operator Equals -Value (“Calipsa Triggered Event - True Alarm”)
$c4 = New-AlarmCondition -Target SourceName -Operator Contains -Value (“MSU-008”)
$order = New-AlarmOrder -Order Descending -Target Timestamp
Get-EventLine -Conditions $c1,$c2,$c3,$c4 -SortOrders $order
Hi @Justin Tierney,
Just to clarify, based on Milestone software terminology are you trying to get a list of alarms or a list of events? It gets a bit confusing since it could be an “alarm” on the camera that causes an “event” in Milestone, and you may or may not have an “alarm definition” configured in Milestone to use that as a trigger to generate an alarm in Milestone.
The Get-EventLine and Get-AlarmLine cmdlets both depend on the New-AlarmCondition and New-AlarmOrder cmdlets to help build a filter, but they’ll return very different results.
So I take it there is an edge analytic setup on the cameras and in the “Events” tab for the cameras in Management Client you’ve enabled those events in Milestone?
Then whether or not you’re creating alarms from those, you want to get a list of all of the occurrences in the last X days, but filtered to only the events from cameras in a particular camera group?
I don’t think the SDK allows you to create a filter condition using multiple device id’s, so it seems like you’d either have to search one device at a time or get all events and filter them after the fact.
I noticed that your $c2 definition says “Timestamp greater than Now” so that’ll prevent you from seeing any results in your query, but that doesn’t solve the “filter by device group” requirement of course.
If you can confirm what the source event is and whether you want alarms or events, I can do a quick test and offer an example.
Cheers,
Josh