简体   繁体   English

为什么即使执行策略为RemoteSigned,我仍需要“ Unblock-File”?

[英]Why do I need “Unblock-File” even though execution policy is RemoteSigned?

I have a batch file that calls powershell script and runs it. 我有一个调用powershell脚本并运行它的批处理文件。

Powershell.exe -ExecutionPolicy RemoteSigned -File %1

%1 argument is the file_name.ps1 %1参数是file_name.ps1

When i run it from my local drive, the script runs fine. 当我从本地驱动器运行它时,脚本运行良好。

however, I moved the scripts to run on a shared drive, and when i try running it from there, it gives this kind of prompt before proceeding: 但是,我将脚本移到了共享驱动器上运行,当我尝试从共享驱动器上运行它时,在继续操作之前会给出以下提示:

Unblock_file提示

The problem with this is autosys has to bypass this prompt, otherwise its giving error. 问题在于autosys必须绕过此提示,否则会给出错误信息。

But why is this even an issue in the shared drive when if i run the script on local drive it doesn't prompt this? 但是,如果我在本地驱动器上运行脚本时却没有提示,为什么共享驱动器中甚至会有这个问题? and what should i do to resolve it? 我应该怎么解决呢?

I tried passing in the Unblock-File -Path some_path in powershell but its apparently not recognized cmdlet. 我尝试在Unblock-File -Path some_path中传递Unblock-File -Path some_path ,但显然无法识别该cmdlet。

Ok, so after being unable to load the zone identification for the file, I tried ByPass policy instead as follows: 好的,因此在无法加载文件的区域标识之后,我尝试按如下所示使用Bypass策略:

Powershell.exe -ExecutionPolicy ByPass -File %1

THAT made it work....instead of RemoteSigned/Unrestricted... 那使它起作用了。。。。而不是RemoteSigned / Unrestricted。

Based on MSDN article here: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-6 基于MSDN的文章, 网址为https : //docs.microsoft.com/zh-cn/powershell/module/microsoft.powershell.core/about/about_about_execution_policies?view=powershell-6

RemoteSigned: Scripts can run. RemoteSigned:脚本可以运行。

Requires a digital signature from a trusted publisher on scripts and configuration files that are downloaded from the Internet (including e-mail and instant messaging programs). 需要从Internet上下载的脚本和配置文件(包括电子邮件和即时消息传递程序)上的可信赖发布者提供数字签名。

Does not require digital signatures on scripts that you have written on the local computer (not downloaded from the Internet). 您在本地计算机上编写的脚本(不是从Internet下载的)上不需要数字签名。

Runs scripts that are downloaded from the Internet and not signed, if the scripts are unblocked, such as by using the Unblock-File cmdlet. 运行脚本,这些脚本是从Internet下载的且未经签名的脚本(如果已解除阻止),例如使用Unblock-File cmdlet。

Unrestricted: Unsigned scripts can run. 不受限制:可以运行未签名的脚本。 (This risks running malicious scripts.) (这有运行恶意脚本的风险。)

Warns the user before running scripts and configuration files that are downloaded from the Internet. 在运行从Internet下载的脚本和配置文件之前警告用户。

but my script was copied locally there from one drive to another, its not downloaded from the internet...and in the file properties, there was no "Unblock" button, and Unblock cmdlet wouldnt work for me anyways. 但是我的脚本是从一个驱动器本地复制到另一个驱动器的,而不是从Internet下载的...在文件属性中,没有“取消阻止”按钮,并且无论如何我都无法取消阻止cmdlet。

So to avoid the warning, the only thing that worked is ByPass 因此,为了避免警告,唯一起作用的是ByPass

Bypass: Nothing is blocked and there are no warnings or prompts. 绕过:没有任何障碍,也没有警告或提示。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 解锁文件-为什么我需要打开一个新会话? - Unblock-File - Why do I need to open a new session? Powershell 网络驱动器上的脚本即使在运行 Unblock-File 后仍然给出安全提示 - Powershell script on network drive still giving security prompt even after running Unblock-File Powershell执行策略remotesigned矛盾? - Powershell execution policy remotesigned contradiction? 运行脚本时的安全警告 - Unblock-File not unblocking file - Security Warning when running scripts - Unblock-File not unblocking file Ansible,如何设置Execution-Policy为RemoteSigned? - In Ansible, how to set Execution-Policy to RemoteSigned? 当执行策略设置为RemoteSigned时,为什么从Internet(azure blob)下载后执行脚本? - Why script is executing after downloaded from internet ( azure blob ) when execution policy is set as RemoteSigned 为什么我的本地创建的脚本不允许在 RemoteSigned 执行策略下运行? - Why is my locally-created script not allowed to run under the RemoteSigned execution policy? 尝试从Internet机运行ps1文件时,unblock-file可以摆脱提示警告 - unblock-file can get rid of prompt warning when try to run ps1 file from internet machine 如何以编程方式取消阻止(IE功能)文件? - How do I programmatically Unblock (IE feature) a file? 为什么即使我以管理员身份运行 windows Powershell 也会出现权限错误? - Why do I get privileges errors even though I run windows Powershell as administrator?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM