Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

powershell execution policy is blocking the scheduled task #27

Closed
scelfo opened this issue Jan 8, 2021 · 2 comments
Closed

powershell execution policy is blocking the scheduled task #27

scelfo opened this issue Jan 8, 2021 · 2 comments

Comments

@scelfo
Copy link
Contributor

scelfo commented Jan 8, 2021

I got this all running if I execute the backup.ps1 script directly in powershell. However, the task in task scheduler was not running and it was really frustrating me.

I have a normal windows 10 installation and my task was running as SYSTEM user, the defaults set up by this project.

I ended up installing psexec so I could run a command problem as the SYSTEM users (instructions: https://www.gabsoftware.com/tips/run-cmd-or-any-process-as-system-account-on-windows/) and was able to determine that my problem was caused by execution policies which were set as Restricted (documentation: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-7.1).

I poked around, found https://blog.netspi.com/15-ways-to-bypass-the-powershell-execution-policy/ and was able to make everything work by simply adding "-ExecutionPolicy Bypass" to the arguments of the restic backup task in task scheduler. I'm filing this to document my problem and fix and I might send a pull request to add "-ExecutionPolicy Bypass" to the task created by install.ps1.

@kmwoley
Copy link
Owner

kmwoley commented Feb 22, 2021

Thanks for reporting this. I think the reason I wasn't encountering this is because I have my execution policy set to RemoteSigned. I'll include this in the next release.

@scelfo
Copy link
Contributor Author

scelfo commented Feb 22, 2021

No problem, happy to help. I'm running your script on a few very clean windows installations with the bare minimum needed to get up and running so hopefully my experience is common.

I have a few other tweaks in the backup script but they aren't useful to others. Notably I'm using scoop to install restic based on https://restic.readthedocs.io/en/latest/020_installation.html#windows and I disable the cleanup logic in the backup script since I'm managing that elsewhere.

@kmwoley kmwoley closed this as completed Feb 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants