diff --git a/foam_sync.ps1 b/foam_sync.ps1 index 5203b1b..9b14a6b 100644 --- a/foam_sync.ps1 +++ b/foam_sync.ps1 @@ -2,6 +2,7 @@ $task = @{ name = 'FoamGitSync' + description = "Periodically synchronizes the Git repository at $scriptDir using $scriptName." freqencyMinutes = 2 } @@ -21,11 +22,8 @@ $logFilePath = Join-Path -Path $logDir -ChildPath "foam_sync.log" Start-Transcript -Path $logFilePath -Append -IncludeInvocationHeader -Force try { - # Wrap main script logic in try for Stop-Transcript in finally - - # --- Script Setup --- $scriptPath = $MyInvocation.MyCommand.Path - $scriptDir = Split-Path -Path $scriptPath -Parent # This is the Git repository root + $scriptDir = Split-Path -Path $scriptPath -Parent $scriptName = (Get-Item $scriptPath).Name Write-Host "Script: $scriptName at $scriptPath" @@ -33,8 +31,6 @@ try { Write-Host "Sync frequency: Every $frequencyMinutes minutes" Write-Host "Log file: $logFilePath" - $taskDescription = "Periodically synchronizes the Git repository at $scriptDir using $scriptName." - # 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)