set execution policy

This topic contains 6 replies, has 3 voices, and was last updated by Profile photo of Richard Siddaway Richard Siddaway 4 months, 4 weeks ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #38418
    Profile photo of Ryan Burton
    Ryan Burton
    Participant

    I am having trouble setting the execution policy. This is the cmdlet that I am using:

    Set-ExecutionPolicy Bypass

    I am using powershell 5.0 and windows 10. I am an advanced home user, but do not work in my field. My research says that once the execution policy is set then it will put a key into the registry and will save it so that you do not have to use the cmdlet every time you start powershell.

    I want powershell to run automatically every time i start or reboot the machine so a shortcut to it is now in the startup folder. but when it runs i get an error:

    . : File C:\Users\Ryan\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 cannot be loaded because running
    scripts is disabled on this system. For more information, see about_Execution_Policies at
    http://go.microsoft.com/fwlink/?LinkID=135170.
    At line:1 char:3
    + . 'C:\Users\Ryan\Documents\WindowsPowerShell\Microsoft.PowerShell_pro ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess

    I think I want to run PS as an administrator from the time it starts when I start the computer or restart it, but I don't know how.

    I tried this:
    http://www.cnet.com/how-to/always-run-a-program-in-administrator-mode-in-windows-10/
    but it didn't work. I've been trying to solve this problem for about 3 hrs. plz help, ty.

    #38419
    Profile photo of Jonathan Warnken
    Jonathan Warnken
    Participant

    in order to run powershell as an administrator do the following
    – Click on the Windows Flag
    – Type Powershell
    – right click on the poweshell icon
    – click on the "Run as Administrator" option
    – Once powershell opens run the command "Set-ExecutionPolicy Bypass"

    That will ensure the the execution policy is set. But why do you want to start powershell everytime you restart? Are you trying to run something to like a logon script? or do you just want the console open so you can use it?
    If you want to run a script on every reboot there are better ways. If you just want the console open, I would not suggest you open it as an administrator.

    #38421
    Profile photo of Ryan Burton
    Ryan Burton
    Participant

    I understand that I can just run it as the administrator from the start menu, but I want the console to open as the administrator everytime I restart or start up the computer. without the execution policy set I cannot run the scripts I write. Having to type this in and start the program every time gets to be time consuming. I am very careful about not opening spam attachments or visiting untrusted websites so while i realize that this could be dangerous, this is what I want to do. Ty.

    #38422
    Profile photo of Ryan Burton
    Ryan Burton
    Participant

    It would be helpful if I could be shown a way to run all programs as the administrator by default without a windows popup warning and by changing just one setting.

    #38423
    Profile photo of Jonathan Warnken
    Jonathan Warnken
    Participant

    If the execution policy is set correctly then the scripts will run, even after reboots.
    Always running everything as Administrator is a very poor security choice. But if you choose to do it that is something better asked of your favorite search engine.
    While it can be done via powershell, I am not comfortable helping someone weaken the security of their system.

    #38424
    Profile photo of Ryan Burton
    Ryan Burton
    Participant

    I understand. I'll just have to start it everytime I start or reboot the computer. I took the shortcut out of the startup folder and started it and it ran the scripts without setting the execution policy or running the program as the administrator so it works fine. just repetitive.

    #38441

    Using ByPass as your default execution policy is a dangerous idea and is definitely NOT recommended best practice.

    form about_execution_policies

    – This execution policy is designed for configurations
    in which a Windows PowerShell script is built in to a
    a larger application or for configurations in which
    Windows PowerShell is the foundation for a program
    that has its own security model.

    RemoteSigned is a much safer option

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.