-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create convert-hawkdaystodates function.
- Loading branch information
1 parent
6eee873
commit 0c41e1a
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |