Reputation: 43
I recently get the powershell message "Execution Policy Changed" message when i execute .ps1 script file
--------------
Execution Policy Change
The execution policy helps protect you from scripts that you do not trust. Changing the execution policy might expose
you to the security risks described in the about_Execution_Policies help topic at
http://go.microsoft.com/fwlink/?LinkID=135170. Do you want to change the execution policy?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"):
---------------
This is unacceptable because i set the unrestricted on the CurrectUser.
----
Scope ExecutionPolicy
----- ---------------
MachinePolicy Undefined
UserPolicy Undefined
Process Undefined
CurrentUser Unrestricted <<< HERE
LocalMachine Undefined
----
Any knows what happens???
This only occurs when machine CPU is very high load (more than 80%) and/or powershell is not cached on RAM.
Thanks in advance guys!!!
PS: Here is mi regedit entries for double-click behaviour:
HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\0\Command =
"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" "-Command" "if((Get-ExecutionPolicy ) -ne 'AllSigned') { Set-ExecutionPolicy -Scope Process Bypass }; & "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -Mta -File '%1'"
Video of the problem i get here
Upvotes: 3
Views: 3618
Reputation: 1884
Try this to observe the behavior over time:
while ($true){
powershell.exe -Command {Get-ExecutionPolicy }
sleep 5
}
Since execution of scripts might be restricted, you need to paste it in PowerShell manually. My current hypothesis is that on a fresh restart / memory wipe the execution policy changes to Undefined
till it is properly loaded again. On way to prevent the popup is to -Force
the change.
Upvotes: 0