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