Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Hawk/functions/Tenant/Start-HawkTenantInvestigation.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@

if (Test-PSFFunctionInterrupt) { return }

# Check if Hawk object exists and is fully initialized
# If Hawk object is missing or incomplete, initialize it interactively
if (Test-HawkGlobalObject) {
Initialize-HawkGlobalObject
}
Expand Down
2 changes: 1 addition & 1 deletion Hawk/functions/User/Start-HawkUserInvestigation.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
process {
if (Test-PSFFunctionInterrupt) { return }

# Check if Hawk object exists and is fully initialized
# If Hawk object is missing or incomplete, initialize it interactively
if (Test-HawkGlobalObject) {
Initialize-HawkGlobalObject
}
Expand Down
53 changes: 1 addition & 52 deletions Hawk/internal/functions/Initialize-HawkGlobalObject.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -452,62 +452,11 @@
}
}

# End date logic remains unchanged except for final +1 day fix
if ($null -eq $EndDate) {
Out-LogFile "Please specify the last day of the search window:" -isPrompt
Out-LogFile " Enter a number of days to go back from today (1-365)" -isPrompt
Out-LogFile " OR enter a specific date in MM/DD/YYYY format" -isPrompt
Out-LogFile " Default is today's date:" -isPrompt -NoNewLine
$EndRead = (Read-Host).Trim()

# End date validation
if ($null -eq ($EndRead -as [DateTime])) {
if ([string]::IsNullOrEmpty($EndRead)) {
[DateTime]$EndDate = (Get-Date).ToUniversalTime().Date
}
else {
Out-LogFile -string "End Date: $EndRead days." -Information
[DateTime]$EndDate = ((Get-Date).ToUniversalTime().AddDays( - ($EndRead - 1))).Date
}

if ($StartDate -gt $EndDate) {
Out-LogFile -string "StartDate cannot be more recent than EndDate" -isError
}
else {
# --- FINAL FIX: Always move to next day at 00:00 UTC ---
$EndDate = $EndDate.ToUniversalTime().Date.AddDays(1)

# Write-Output ""
# Out-LogFile -string "End date set to: ${EndDate}Z`n" -Information
}
}
elseif (!($null -eq ($EndRead -as [DateTime]))) {
[DateTime]$EndDate = (Get-Date $EndRead).ToUniversalTime().Date

if ($StartDate -gt $EndDate) {
Out-LogFile -string "EndDate is earlier than StartDate. Setting EndDate to today." -isWarning
[DateTime]$EndDate = (Get-Date).ToUniversalTime().Date
}
elseif ($EndDate -gt ((Get-Date).ToUniversalTime().AddDays(1))) {
Out-LogFile -string "EndDate too far in the future. Setting EndDate to today." -isWarning
[DateTime]$EndDate = (Get-Date).ToUniversalTime().Date
}

# --- FINAL FIX: Always move to next day at 00:00 UTC ---
$EndDate = $EndDate.ToUniversalTime().Date.AddDays(1)

# Out-LogFile -string "End date set to: ${EndDate}Z`n" -Information
}
else {
Out-LogFile -string "Invalid date information provided. Could not determine if this was a date or an integer." -isError
}
}

# --- AFTER the EndDate block, do a final check to "re-anchor" StartDate if it was given in days ---
if ($StartDays -gt 0) {
# Recalculate StartDate based on EndDate = $EndDate and StartDays = $StartDays
Out-LogFile -string "End date set to midnight UTC of next day to include all data from $($EndDate.AddDays(-1).Date.ToString('yyyy-MM-dd'))Z" -Information
$StartDate = $EndDate.AddDays(-1).AddDays(-$StartDays).Date
$StartDate = $EndDate.AddDays(-$StartDays).Date

# (Optional) Additional validations again if necessary:
if ($StartDate -gt (Get-Date).ToUniversalTime()) {
Expand Down
4 changes: 2 additions & 2 deletions Hawk/internal/functions/Out-Report.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@
}

# We need to check if an entity with the ID $identity already exists
if ($reportxml.report.entity.identity.contains($Identity)) { }
# Didn't find and entity so we are going to create the whole thing and once
if ($reportxml.report.entity | Where-Object { $_.identity -eq $Identity }) { }
# Didn't find an entity so we are going to create the whole thing at once
else {
# Create all of the needed elements
$newentity = $reportxml.CreateElement("entity")
Expand Down
8 changes: 4 additions & 4 deletions Hawk/internal/functions/Test-HawkGlobalObject.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ Function Test-HawkGlobalObject {

.EXAMPLE
Test-HawkGlobalObject
Returns $true if Hawk object is properly initialized, $false otherwise.
.OUTPUTS
Boolean indicating if reinitialization is needed
Returns $true if Hawk object needs initialization (missing or incomplete), $false if properly initialized.

.OUTPUTS
Boolean indicating if reinitialization is needed ($true = needs init, $false = already initialized)
#>
[CmdletBinding()]
[OutputType([bool])]
Expand Down
21 changes: 1 addition & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,37 +101,18 @@ For critical issues or inquiries, email hawkpsmodule@gmail.com.

## **Overview**

<<<<<<< HEAD

Hawk, the open-source PowerShell module, collects limited usage data to help improve the module by identifying the most frequently used features. This data assists in prioritizing updates, enhancements, and new functionality.

## **What Data is Collected?**

Hawk collects **only** the names of the functions that are executed.

✅ **Collected Data:**

- Function names that are run within Hawk.

❌ **Not Collected:**

=======
Hawk, the open-source PowerShell module, collects limited usage data to help improve the module by identifying the most frequently used features. This data assists in prioritizing updates, enhancements, and new functionality.

## **What Data is Collected?**

Hawk collects **only** the names of the functions that are executed.

✅ **Collected Data:**

- Function names that are run within Hawk.
- Region of use

❌ **Not Collected:**

> > > > > > > 4fc2a6fce93b52e0358c9de9e1ad81dfa8779220

- No user-identifiable data.
- No environmental or system data.
- No script inputs, outputs, or arguments.
- No personal, confidential, or sensitive data.
- No data is shared or sold.
Expand Down
Loading