I have a simple autohotkey script
!+l:: RunWait, PowerShell -NoExit -C "Import-Module D:\projects\changescreensaver\changescreensaver.psm1; Set-ScreenSaverTimeout 1;"
But it won't let me load my ps profile or do the import-module and gives me an execution policy error:
Import-Module : File D:\projects\changescreensaver\changescreensaver.psm1 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.
On my terminal, Get-ExecutionPolicy -List
returns
C:\Users\someone>Get-ExecutionPolicy -List
Scope ExecutionPolicy
----- ---------------
MachinePolicy Undefined
UserPolicy Undefined
Process Undefined
CurrentUser Undefined
LocalMachine RemoteSigned
but within my script, returns
Scope ExecutionPolicy
----- ---------------
MachinePolicy Undefined
UserPolicy Undefined
Process Undefined
CurrentUser Undefined
LocalMachine Undefined
I can just pass it -ExecutionPolicy Bypass
, but I'd still like to understand: Why are my ExecutionPolicy values different when invoking PS from AHK?