Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Powershell : Execution Policy

I have been running my code for past few months by doing this -

Set-ExecutionPolicy Unrestricted

But, something weird is happening and I am getting this error always -

Windows PowerShell updated your execution policy successfully, but the setting is overridden by a policy defined at a more specific scope. Due to the override, your shell will retain its current effective execution policy of "Unrestricted". Type "Get-ExecutionPolicy -List" to view your execution policy settings. For more information, please see "Get-Help Set-ExecutionPolicy."

I have referred these links but no luck -

  • http://blogs.msdn.com/b/pasen/archive/2011/12/07/set-executionpolicy-windows-powershell-updated-your-execution-policy-successfully-but-the-setting-is-overridden-by-a-policy-defined-at-a-more-specific-scope.aspx

  • http://blog.whatsupduck.net/2010/09/issues-with-configuring-powershell.html

  • http://www.howtogeek.com/106273/how-to-allow-the-execution-of-powershell-scripts-on-windows-7/

    I am loading the Powershell using C# on a 64-bit Windows 7 via a 32-Bit Winforms Application using .Net 4.0

    What is the exact setting which I need to do such that I do not get this error on any system ? [Everything was working fine]. What should these values be on any system such that I am able to call Powershell from C# seamlessly -

Get-ExecutionPolicy -List

MachinePolicy                                                           
UserPolicy                                                           
Process                                                        
CurrentUser                                                        
LocalMachine
like image 900
Angshuman Agarwal Avatar asked Nov 12 '22 22:11

Angshuman Agarwal


1 Answers

You should see output like this from Get-ExecutionPolicy -List:

        Scope ExecutionPolicy
        ----- ---------------
MachinePolicy       Undefined
   UserPolicy       Undefined
      Process       Undefined
  CurrentUser       Undefined 
 LocalMachine    RemoteSigned

Once you see the scope that has the undesired setting, you can reset it like so:

Set-ExecutionPolicy Undefined -Scope <scope-name>

That is assuming you have permission to do so.

like image 131
Keith Hill Avatar answered Nov 15 '22 13:11

Keith Hill