From 471cf57b7eb5c54a789bbe34e5799246fe5b8c52 Mon Sep 17 00:00:00 2001 From: Tony Scelfo Date: Fri, 8 Jan 2021 14:17:34 -0700 Subject: [PATCH] Add '-ExecutionPolicy Bypass' to the task scheduler arguments to avoid the issue described in https://github.com/kmwoley/restic-windows-backup/issues/27. --- install.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.ps1 b/install.ps1 index aa8df60..ad590ea 100644 --- a/install.ps1 +++ b/install.ps1 @@ -43,7 +43,7 @@ $backup_task_name = "Restic Backup" $backup_task = Get-ScheduledTask $backup_task_name -ErrorAction SilentlyContinue if($null -eq $backup_task) { try { - $task_action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument '-NonInteractive -NoLogo -NoProfile -Command ".\backup.ps1; exit $LASTEXITCODE"' -WorkingDirectory $InstallPath + $task_action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument '-ExecutionPolicy Bypass -NonInteractive -NoLogo -NoProfile -Command ".\backup.ps1; exit $LASTEXITCODE"' -WorkingDirectory $InstallPath $task_user = New-ScheduledTaskPrincipal -UserId "NT AUTHORITY\SYSTEM" -RunLevel Highest $task_settings = New-ScheduledTaskSettingsSet -RestartCount 4 -RestartInterval (New-TimeSpan -Minutes 15) -ExecutionTimeLimit (New-TimeSpan -Days 3) -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -DontStopOnIdleEnd -MultipleInstances IgnoreNew -IdleDuration 0 -IdleWaitTimeout 0 -StartWhenAvailable -RestartOnIdle $task_trigger = New-ScheduledTaskTrigger -Daily -At 4:00am