Skip to content

Commit 7df4bdb

Browse files
committed
Add search date as the core
1 parent a774026 commit 7df4bdb

File tree

2 files changed

+17
-23
lines changed

2 files changed

+17
-23
lines changed

examples/Exabeam/Invoke-ExaExportFHK.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ for ($day = $DaysBetween; $day -ge 0; $day--) {
129129

130130
# Get data for this time block with precise start and end hours
131131
# Each block is distinct: startHour:00:00 to endHour:59:59
132-
$SearchResults = Get-LrtExaFHKResults -Days 1 -StartHour $startHour -EndHour $endHour -Verbose
132+
# Pass the specific date and time range parameters
133+
$SearchResults = Get-LrtExaFHKResults -SearchDate $ProcessDate -StartHour $startHour -EndHour $endHour -Verbose
133134

134135
if ($SearchResults.rows) {
135136
$Rows = $SearchResults.rows | Sort-Object approxLogTime

src/Public/Exabeam/Search/Get-LrtExaFHKResults.ps1

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)