diff --git a/foam_sync.ps1 b/foam_sync.ps1 index 00f5fcb..3dbfd0d 100644 --- a/foam_sync.ps1 +++ b/foam_sync.ps1 @@ -29,7 +29,7 @@ try { # Run as the user who executes this script. $taskPrincipal = New-ScheduledTaskPrincipal -UserId $env:USERNAME -LogonType Interactive - $trigger = New-ScheduledTaskTrigger -Once -At (Get-Date) -RepetitionInterval (New-TimeSpan -Minutes $frequencyMinutes) + $trigger = New-ScheduledTaskTrigger -Once -At (Get-Date) -RepetitionInterval $(New-TimeSpan -Minutes $frequencyMinutes) $action = New-ScheduledTaskAction -Execute $taskExecute -Argument $taskArguments # Task settings @@ -85,7 +85,6 @@ try { catch { Write-Warning "Failed to update scheduled task '$taskName' in-place. Error: $($_.Exception.Message)" Write-Warning "The task remains in its previous state. Manual intervention may be required or re-run with Administrator privileges." - # We intentionally DO NOT unregister here to avoid the scenario you described. } } }