I recently encountered an issue running a Powershell script; whereby running of the script resulted in the following error message:
File C:\Scripts\MyAwesomeScript.ps1 cannot be loaded because the execution of scripts is disabled on this system. Please see "get-help about_signing" for more details.
I did some digging on the error and found that the machine was configured to use the default Powershell execution policy, which was restricting me from running my script. More information on this topic can be found here.
As it turned out, I did not have local admin privileges on the machine, which means I could not change the execution policy according to my requirements. However, after a bit of additional digging I came across the following method for bypassing the execution policy:
powershell -ExecutionPolicy Bypass -File C:\Scripts\MyAwesomeScript.ps1
I find it very bizarre that Microsoft blocks execution of unsigned scripts by default (assuming for security reasons), but allows non-admin users to bypass this measure with the use of a simple command parameter. Maybe there's a good reason for this, but in the limited amount of research I've done on this I have not found an explanation.