1
votes

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

1
Why do you have this registry entry? Do you change the ExecutionPolicy that often? I would just change it once to AllSigned instead of checking it every time...T-Me
You get the prompt because Unrestricted is not equal AllSignedT-Me
Hi T-me but how you explain the strange prompt pop-ups one time, i close window and when reopen, the message not pop-up again? ```EverGreen
Just viewed the Vid... Good thing I had headphones... Maybe you should review it with sound before uploading... I don't know what you are caching but the active executionPolicy seems to change over time after your memory wipe. Does the behavior just occure when you wipe the memory or in other situations too (like reboot)?T-Me
HAHAHAHA, sorry for the sound. But is strange. On clear random boot i get pop-up's. Not all time. I clean caches only to show the problem. ExecutionPolicy change when clear caches?. I assume this is a Microsoft FAULT!!!EverGreen

1 Answers

0
votes

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.