[英]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. Windows PowerShell已成功更新您的执行策略,但该设置被更具体范围内定义的策略覆盖。 Due to the override, your shell will retain its current effective execution policy of "Unrestricted". 由于覆盖,您的shell将保留其当前有效的“Unrestricted”执行策略。 Type "Get-ExecutionPolicy -List" to view your execution policy settings. 键入“Get-ExecutionPolicy -List”以查看执行策略设置。 For more information, please see "Get-Help Set-ExecutionPolicy." 有关详细信息,请参阅“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://blogs.msdn.com/b/pasen/archive/2011/12/07/set-executionpolicy-windows-powershell-updated-your-execution-policy-successfully-but-the-setting-is-overridden-通过-A-策略定义-AT-A-更特定scope.aspx
http://blog.whatsupduck.net/2010/09/issues-with-configuring-powershell.html 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/ 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 我使用.Net 4.0通过32位Winforms应用程序在64位Windows 7上使用C#加载Powershell
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 - 这些值应该在任何系统上应该是什么,以便我能够无缝地从C#调用Powershell -
Get-ExecutionPolicy -List Get-ExecutionPolicy -List
MachinePolicy UserPolicy Process CurrentUser LocalMachine
You should see output like this from Get-ExecutionPolicy -List
: 你应该从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. 假设您有权这样做。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.