foam_sync.ps1 (LIFEBALANCE) 2025-06-19T00:39:50Z

This commit is contained in:
Ben Miller
2025-06-19 00:39:50 -06:00
parent d595694269
commit 2f4f8e11da

View File

@ -49,9 +49,10 @@ $taskDescription = "Periodically synchronizes the Git repository at $scriptDir u
# Run as the user who executes this script.
$taskPrincipal = New-ScheduledTaskPrincipal -UserId $env:USERNAME -LogonType Interactive
# Define a very long duration (e.g., 100 years) instead of [TimeSpan]::MaxValue
$practicallyIndefiniteDuration = New-TimeSpan -Days (365 * 100 + 25) # Account for leap years over 100 years
# Trigger configuration
$trigger = New-ScheduledTaskTrigger -Once -At (Get-Date) -RepetitionInterval (New-TimeSpan -Minutes $frequencyMinutes) -RepetitionDuration ([TimeSpan]::MaxValue)
$trigger = New-ScheduledTaskTrigger -Once -At (Get-Date) -RepetitionInterval (New-TimeSpan -Minutes $frequencyMinutes) -RepetitionDuration $practicallyIndefiniteDuration
# Action configuration:
# We use an indirection technique to ensure the window is truly hidden.
@ -110,7 +111,7 @@ try {
$triggerMatches = $false
if ($currentTrigger -is [Microsoft.Management.Infrastructure.CimInstance] `
-and $currentTrigger.RepetitionInterval.TotalMinutes -eq $frequencyMinutes `
-and $currentTrigger.RepetitionDuration -eq ([TimeSpan]::MaxValue)) {
-and $currentTrigger.RepetitionDuration -eq $practicallyIndefiniteDuration) {
$triggerMatches = $true
}