Skip to content

Commit

Permalink
Create convert-hawkdaystodates function.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonnybottles committed Jan 13, 2025
1 parent 6eee873 commit 0c41e1a
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions Hawk/internal/functions/Convert-HawkDaysToDate.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
Function Convert-HawkDaysToDate {
<#
.SYNOPSIS
Converts the DaysToLookBack parameter into a StartDate and EndDate for use in Hawk investigations.
.DESCRIPTION
This function takes the number of days to look back from the current date and calculates the corresponding
StartDate and EndDate in UTC format. The StartDate is calculated by subtracting the specified number of days
from the current date, and the EndDate is set to one day in the future (to include the entire current day).
.PARAMETER DaysToLookBack
The number of days to look back from the current date. Must be between 1 and 365.
.OUTPUTS
A PSCustomObject with two properties:
- StartDate: The calculated start date in UTC format.
- EndDate: The calculated end date in UTC format (one day in the future).
.EXAMPLE
Convert-HawkDaysToDates -DaysToLookBack 30
Returns a StartDate of 30 days ago and an EndDate of tomorrow in UTC format.
.NOTES
This function ensures that the date range does not exceed 365 days and that the dates are properly formatted
for use with Hawk investigation functions.
#>

[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[ValidateRange(1, 365)]
[int]$DaysToLookBack
)

# Calculate the dates
$startDate = (Get-Date).ToUniversalTime().AddDays(-$DaysToLookBack).Date
$endDate = (Get-Date).ToUniversalTime().AddDays(1).Date

# Return the dates as a PSCustomObject
[PSCustomObject]@{
StartDate = $startDate
EndDate = $endDate
}
}

0 comments on commit 0c41e1a

Please sign in to comment.