Windows Powershell giving “is not digitally signed” error

I was getting this error:

File C:\Scripts\XXXXXX.ps1 cannot be loaded. The file C:\Scripts\XXXXXX.ps1 is not digitally signed. You cannot run this script on the current system.

To fix this, run this command:

Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass