foam_sync.ps1 (LIFEBALANCE) 2025-06-19T00:39:50Z
This commit is contained in:
@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user