Execution policy prompt the first time powershell script runs after reboot

Welcome Forums General PowerShell Q&A Execution policy prompt the first time powershell script runs after reboot

This topic contains 1 reply, has 2 voices, and was last updated by

 
Keymaster
2 years, 4 months ago.

  • Author
    Posts
  • #46247

    Participant
    Points: 0
    Rank: Member

    I have a PowerShell script I wish to use to automate something. I run it by right clicking on it and choosing "Run with PowerShell".

    I have run Set-ExecutionPolicy Bypass in both 32- and 64-bit PowerShell, and verified it with Get-ExecutionPolicy.

    Still, the first time I try to run the script after every reboot, I get this prompt:

    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 Suspend [?] Help (default is "N"):

    If I just close the PowerShell window and run it again, there is no prompt. Whether I enter Y or N to the prompt, the script runs.

    There is nothing funny in the script, just `echo "Test"`. The same thing happens on three different computers, Win 8.1, Win 10 and a virtualized Win 10. All of them have PowerShell 5.0.

    What am I doing wrong? How can I get rid of this prompt?

  • #46348

    Keymaster
    Points: 1,638
    Helping HandTeam Member
    Rank: Community Hero

    Does the script itself include Set-ExecutionPolicy?

The topic ‘Execution policy prompt the first time powershell script runs after reboot’ is closed to new replies.