#!/usr/bin/env pwsh # Register the daily 10:30 AM git sync task for this repository. param( [string]$TaskName = "Obsidian-Git-Sync-Daily", [string]$RepoPath = "D:\fork_project\obsidian-notes" ) $scriptPath = Join-Path $RepoPath "git_sync_daily.ps1" if (-not (Test-Path $scriptPath)) { throw "Sync script not found: $scriptPath" } $existing = Get-ScheduledTask -TaskName $TaskName -ErrorAction SilentlyContinue if ($existing) { Unregister-ScheduledTask -TaskName $TaskName -Confirm:$false Write-Host "Removed existing task: $TaskName" } $action = New-ScheduledTaskAction -Execute "powershell.exe" ` -Argument "-NoProfile -ExecutionPolicy Bypass -WindowStyle Hidden -File `"$scriptPath`" -RepoPath `"$RepoPath`"" $trigger = New-ScheduledTaskTrigger -Daily -At 10:30AM $settings = New-ScheduledTaskSettingsSet ` -AllowStartIfOnBatteries ` -DontStopIfGoingOnBatteries ` -StartWhenAvailable Register-ScheduledTask -TaskName $TaskName ` -Action $action ` -Trigger $trigger ` -Settings $settings ` -Description "Daily 10:30 AM git sync for obsidian-notes and InBox/Gantt sync" Write-Host "Task '$TaskName' registered." Write-Host "Schedule: daily at 10:30 AM" Write-Host "Script: $scriptPath"