diff --git a/Hawk/functions/Tenant/Start-HawkTenantInvestigation.ps1 b/Hawk/functions/Tenant/Start-HawkTenantInvestigation.ps1 index 05622b5..1c3c162 100644 --- a/Hawk/functions/Tenant/Start-HawkTenantInvestigation.ps1 +++ b/Hawk/functions/Tenant/Start-HawkTenantInvestigation.ps1 @@ -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 } diff --git a/Hawk/functions/User/Start-HawkUserInvestigation.ps1 b/Hawk/functions/User/Start-HawkUserInvestigation.ps1 index 5074839..0861870 100644 --- a/Hawk/functions/User/Start-HawkUserInvestigation.ps1 +++ b/Hawk/functions/User/Start-HawkUserInvestigation.ps1 @@ -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 } diff --git a/Hawk/internal/functions/Initialize-HawkGlobalObject.ps1 b/Hawk/internal/functions/Initialize-HawkGlobalObject.ps1 index 63f1ea4..4880f3b 100644 --- a/Hawk/internal/functions/Initialize-HawkGlobalObject.ps1 +++ b/Hawk/internal/functions/Initialize-HawkGlobalObject.ps1 @@ -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()) { diff --git a/Hawk/internal/functions/Out-Report.ps1 b/Hawk/internal/functions/Out-Report.ps1 index e29a4a3..2a34739 100644 --- a/Hawk/internal/functions/Out-Report.ps1 +++ b/Hawk/internal/functions/Out-Report.ps1 @@ -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") diff --git a/Hawk/internal/functions/Test-HawkGlobalObject.ps1 b/Hawk/internal/functions/Test-HawkGlobalObject.ps1 index f27c63a..1a1c352 100644 --- a/Hawk/internal/functions/Test-HawkGlobalObject.ps1 +++ b/Hawk/internal/functions/Test-HawkGlobalObject.ps1 @@ -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])] diff --git a/README.md b/README.md index 0db4074..835d3a4 100644 --- a/README.md +++ b/README.md @@ -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.