This is a reminder for myself: “powershell.exe -File test.ps1 -ExecutionPolicy Bypass” doesn’t work.
“File C:\Demo\hello.ps1 cannot be loaded because running scripts is disabled on this system.”
It’s because of this:
-ExecutionPolicy Bypass is not parsed as an option, but as arguments to option -File.
The correct option order is this:
powershell.exe -ExecutionPolicy Bypass -File hello.ps1
Article Link: https://blog.didierstevens.com/2017/08/29/quickpost-powershell-options-order/