# Update Existing "Tingting Guardian" Task to use new daily_check system
# Run this script as Administrator

Write-Host "Updating 'Tingting Guardian' task..." -ForegroundColor Cyan

# Get existing task
$task = Get-ScheduledTask -TaskName "Tingting Guardian"

# Create new action (WSL + trigger_check.sh)
$action = New-ScheduledTaskAction `
    -Execute "wsl" `
    -Argument "-e bash -c ""cd '/mnt/e/Users/Alexis Trouvé/Documents/Projets/couple_matters/daily_check' && ./trigger_check.sh"""

# Create triggers (3x daily: 07:00, 14:00, 21:00)
$trigger1 = New-ScheduledTaskTrigger -Daily -At 07:00
$trigger2 = New-ScheduledTaskTrigger -Daily -At 14:00
$trigger3 = New-ScheduledTaskTrigger -Daily -At 21:00

# Combine triggers
$triggers = @($trigger1, $trigger2, $trigger3)

# Update task
Set-ScheduledTask -TaskName "Tingting Guardian" `
    -Action $action `
    -Trigger $triggers

Write-Host "Task updated successfully!" -ForegroundColor Green
Write-Host ""
Write-Host "New configuration:" -ForegroundColor Yellow
Write-Host "- Action: WSL bash + trigger_check.sh"
Write-Host "- Triggers: Daily at 07:00, 14:00, 21:00"
Write-Host ""
Write-Host "Testing task now..." -ForegroundColor Cyan
Start-ScheduledTask -TaskName "Tingting Guardian"

Write-Host "Done! Check daily_check/daily_check.log to verify it worked." -ForegroundColor Green
