I've created a Custom SQL Alert trigger condition on IPAM nodes which looks like this:
select IPAM_NodeReportView.IPAddress, IPAM_NodeReportView.IPNodeId from IPAM_NodeReportView WHERE ipnodeid in (SELECT a.ipnodeid FROM IPAM_IPHistoryReport a INNER JOIN (SELECT ipnodeid, max(IPAM_IPHistoryReport.Time) as tt from IPAM_IPHistoryReport Group by ipnodeid) b on a.IPNodeId=b.IPNodeId and a.Time > dateadd(minute, -100, GetDate()) where (a.FromValue='Available' and a.IntoValue='Used') or (a.FromValue='Available' and a.IntoValue='Reserved'))
The SQL works, the alert is triggered and it will detect a status change of an IP in IPAM.
Eventually, I would like to run a powershell program that will use the IPs from the above query. I've started with sending myself an email with the exact query in the message.
But the mail I get is:
MACRO SQL ERROR - String cannot be of zero length.
Parameter name: oldValue