kmwoley / restic-windows-backup

Powershell scripts to run Restic backups on Windows
MIT License
330 stars 68 forks source link

Error during setup: install.ps1 cannot be loaded because running scripts is disabled on this system #48

Closed ianneub closed 3 years ago

ianneub commented 3 years ago

On my first installation of restic-windows-backup I hit this problem:

.\install.ps1 : File C:\restic\install.ps1 cannot be loaded because running scripts is disabled on this system. For
more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.

Not using Windows too much, I wasn't sure how to enable this. A quick search later and I was able to find a solution pretty easily:

  1. https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-7.1
  2. https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.security/set-executionpolicy?view=powershell-7.1

Run this before ./install.ps1:

Set-ExecutionPolicy Bypass -Scope Process

I thought it might help someone else in the future if they run into this issue as well, so posting the solution here.

kmwoley commented 3 years ago

Really good feedback! Thanks for sharing it. I added some instructions to the readme. I would suggest using the RemoteSigned execution policy; it's a little safer / less permissive. It does mean you need to 'unblock' the execution of any file that gets downloaded, so it's an bit of an annoyance, but I think it's worth the added security.