问题标签 [executionpolicy]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
powershell - 为什么我的本地创建的脚本不允许在 RemoteSigned 执行策略下运行?
由于此问题继续吸引被问题主体驳斥或未解决实际问题的回答, 请阅读以下您需要了解的简单摘要:
- 这不是“为什么我的 PowerShell 的默认安装不运行脚本?” 问题。
- 这不是“为什么我安装的 PowerShell 不能运行从 Internet 下载的脚本?” 问题。
- 问题是为什么
RemoteSigned
执行策略会在不应该执行的情况下阻止脚本执行。RemoteSigned
是我要使用的唯一执行策略。 我知道还有其他限制较少的政策可用。如果这些政策是可接受的替代品,我会直接使用它们,而这个问题将不存在。- 执行策略已设置为
RemoteSigned
。 将其更改RemoteSigned
为RemoteSigned
不是解决方案。- 脚本文件在本地创建和存储。
- 脚本文件未被阻止。 脚本文件从未被阻止(参见前一点)。
- 脚本文件不能被解除阻塞,因为没有什么可以解除阻塞(见前一点)。
- 脚本文件由管理员(试图)执行。
Windows PowerShell
是唯一涉及的应用程序。 不相关Windows PowerShell ISE
,也不Command Prompt
相关任何其他工具或编辑器。- 问题的原因已经确定(见接受的答案)。近 8 年后,我认为所有其他明显的解释,无论是否适用,都已发布。如果您不这么认为,请在添加之前完整阅读问题和现有答案。
我在 64 位 Windows 7 Professional 上使用 Windows PowerShell 2.0。我有一个脚本,Desktop
当我尝试运行它时会导致以下错误:
我既是域管理员又是本地管理员,如果我运行Get-ExecutionPolicy -List
,我可以看到我为配置 PowerShell 而创建的在机器级别Group Policy Object
正确应用了执行策略:RemoteSigned
我自己在 中创建了脚本Notepad
,并使用了Sysinternals的streams
实用程序和文件Properties
对话框来确认该脚本没有被视为来自互联网。如果我将脚本复制到域服务器上的网络共享,则允许执行。如果我运行Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope LocalMachine
,则仍然不允许执行本地脚本,这是有道理的,因为MachinePolicy
范围内的执行策略将优先。
正如about_Execution_Policies
(当前;在问题时)所记录的,该RemoteSigned
政策意味着:
脚本可以运行。
对于从 Internet 下载的脚本和配置文件(包括电子邮件和即时消息程序),需要来自受信任的发布者的数字签名。
不需要对您已运行且已在本地计算机上编写的脚本(不是从 Internet 下载)进行数字签名。
运行来自 Internet 以外来源的未签名脚本和已签名但恶意脚本的风险。
我的脚本没有签名,但由于它是在本地创建和执行的,它应该满足上面的第三个要点。所以...
- 为什么不允许我的脚本运行?
- 为什么 PowerShell 抱怨我的脚本“没有经过数字签名”,而该要求只适用于来自 Internet 的文件?
- 为什么 PowerShell 从网络共享运行时不再关心脚本未签名?
windows - 如何禁用安全警告
如何禁用安全警告:
我尝试将策略设置为不受限制。
操作系统是windows server 2003。
我试图执行的脚本在网络驱动器中。
powershell - 通过 nant 运行时,Powershell 脚本失败
我有几个团队成员无法通过 nant 运行 powershell 脚本。当他们这样做时,他们得到ExectutionPolicy
(不够高,仍然设置为默认值)。但是,它们 Set-ExecutionPolicy RemoteSigned
在 powershell 控制台中运行,并且可以直接运行 powershell 脚本。关于出了什么问题的任何想法?
c# - 仅从 c# 运行签名的 powershell 脚本
我有一个下载脚本然后运行它的 Windows 服务。
我一直在努力让我的 Windows 服务更安全,让它只接受签名的 power-shell 脚本。
我在服务器上运行了 Set-ExecutionPolicy AllSigned 命令,这适用于 windows power shell 命令提示符。
但是,即使 set-executionpolicy 设置为受限,我的代码仍会同时运行已签名和未签名的脚本。
我尝试了两种方法:
RunspaceConfiguration runspaceConfiguration = RunspaceConfiguration.Create();
还有另一种方法:
在这两种情况下,代码也会运行未签名的脚本。
我错过了什么吗?
c# - 使用 C# 中的调用命令引发异常
我从 powershell 终端尝试了以下案例:
这工作正常。但是,当我通过 C# 的调用命令尝试相同的事情时,它会引发以下异常:
我正在尝试使用以下代码:
powershell - 脚本执行策略
我有一个 PowerShell 执行策略问题。起初我以为这只是因为我试图从 GitHub 项目中运行脚本,但我什至无法运行自己的脚本。我过去没有这个问题,我不知道从那时到现在会发生什么变化。
powershell - Windows 中的 Powershell 脚本执行失败
我已经编写了一个 powershell 脚本,但是当我尝试运行它时,我收到一条错误消息,提示无法加载 .ps1 文件并且它没有经过数字签名。
Powershell.exe -ExecutionPolicy Unrestricted -File script.ps1
请帮我解决这个问题。
python - Powershell Execution Policy is restricted, but only when run through python
I have a Windows Server 2008 box. I have run, as administrator, in powershell Set-ExecutionPolicy Unrestricted. When I run powershell Get-ExecutionPolicy
, it returns Unrestricted.
I have created a .bat file which exhibits the issue I am seeing. The .bat file, test.bat, is only one line, powershell Get-ExecutionPolicy
. When I open command prompt and run test.bat, "Unrestricted" is printed to the screen.
If I run the following python script however,
"Restricted" is printed to the screen. How is this setting different when being run from Python's subprocess.Popen? I am not seeing the issue on a Windows 7 machine I have, where I have performed an identical workflow.
windows - Jenkins 执行 PowerShell 脚本
我正在尝试从 Jenkins 运行 PowerShell 脚本,但它似乎完全忽略了执行策略!这可以通过直接执行 powershell.exe 或使用PowerShell 插件来实现
附加信息:
Jenkins 作为 Windows 服务运行(使用本地系统帐户,非交互式)。连接到该服务器并检查执行策略确实是RemoteSigned
:
但是,在运行 Jenkins 构建时,情况并非如此。Get-ExecutionPolicy -List
这是在构建步骤中执行的输出:
我还尝试从构建步骤中明确设置它,没有。
我错过了什么?
powershell - Powershell:AuthorizationManager 检查失败(3 个或更多文件)(“ExecutionPolicy”:“RemoteSigned”或“Unrestricted”)
当我尝试执行文件 3(auth_test2.ps1)时遇到问题,然后我收到错误消息(和输出):
文件 1 (auth_test0.ps1):
文件 2 (auth_test1.ps1):
文件 3(auth_test2.ps1):
“ExecutionPolicy”是“RemoteSigned”,“Unrestricted”没有区别......我希望有人能帮我解决问题。