@@ -24,18 +24,18 @@ Function Get-LrtExaFHKResults {
2424
2525 [CmdletBinding ()]
2626 Param (
27- [Parameter (Mandatory = $false , ValueFromPipeline = $true , Position = 0 )]
28- [ValidateNotNull ()]
29- [int ] $Days = 1 ,
30-
31- [Parameter (Mandatory = $false , Position = 1 )]
27+ [Parameter (Mandatory = $false , Position = 0 )]
3228 [ValidateNotNull ()]
3329 [int ] $StartHour = 0 ,
3430
35- [Parameter (Mandatory = $false , Position = 2 )]
31+ [Parameter (Mandatory = $false , Position = 1 )]
3632 [ValidateNotNull ()]
3733 [int ] $EndHour = 23 ,
3834
35+ [Parameter (Mandatory = $false , Position = 2 )]
36+ [ValidateNotNull ()]
37+ [DateTime ] $SearchDate = (Get-Date ),
38+
3939 [Parameter (Mandatory = $false , Position = 3 )]
4040 [ValidateNotNull ()]
4141 [pscredential ] $Credential = $LrtConfig.Exabeam.ApiKey
@@ -59,9 +59,10 @@ Function Get-LrtExaFHKResults {
5959
6060 # Define HTTP URI
6161 $RequestUrl = $BaseUrl + " search/v2/events"
62- $CurrentDate = (Get-Date ).ToUniversalTime()
63- # Temporary variables
64- $PastDate = $CurrentDate.Date.AddDays (- $Days )
62+
63+ # Use SearchDate parameter (defaults to today if not provided)
64+ $QueryDate = $SearchDate.Date
65+ Write-Verbose " [$Me ]: Using search date: $QueryDate "
6566
6667 # Validate hour parameters (between 0-23)
6768 $ValidatedStartHour = [Math ]::Max(0 , [Math ]::Min(23 , $StartHour ))
@@ -75,20 +76,12 @@ Function Get-LrtExaFHKResults {
7576 Write-Verbose " [$Me ]: Using time range: $ValidatedStartHour: 00 to $ValidatedEndHour: 59 "
7677
7778 # Create precise time range for this query with guaranteed non-overlapping time windows
78- $startTime = $PastDate .AddHours ($ValidatedStartHour ).ToString(" yyyy-MM-ddTHH:00:00.000Z" )
79+ $startTime = $QueryDate .AddHours ($ValidatedStartHour ).ToString(" yyyy-MM-ddTHH:00:00.000Z" )
7980
80- # If we're querying the same day, use the end hour with precise formatting
81- # If we're querying multiple days, handle differently
82- if ($Days -le 1 ) {
83- # Create an exclusive end time that doesn't overlap with the next time block
84- # End time is the last second of the specified end hour (HH:59:59)
85- $endTime = $PastDate.AddHours ($ValidatedEndHour ).AddMinutes(59 ).AddSeconds(59 ).ToString(" yyyy-MM-ddTHH:mm:ss.000Z" )
86- Write-Verbose " [$Me ]: Time window: $startTime to $endTime "
87- } else {
88- # For multi-day queries, keep the existing behavior
89- $endTime = $PastDate.AddDays ($Days ).ToString(" yyyy-MM-ddT23:59:59.000Z" )
90- Write-Verbose " [$Me ]: Multi-day time window: $startTime to $endTime "
91- }
81+ # Create precise end time for the time block (last second of the end hour)
82+ # End time is the last second of the specified end hour (HH:59:59)
83+ $endTime = $QueryDate.AddHours ($ValidatedEndHour ).AddMinutes(59 ).AddSeconds(59 ).ToString(" yyyy-MM-ddTHH:mm:ss.000Z" )
84+ Write-Verbose " [$Me ]: Precise time window: $startTime to $endTime "
9285
9386
9487 # Check preference requirements for self-signed certificates and set enforcement for Tls1.2
0 commit comments