即使运行 Unblock-File 后,网络驱动器上的 Powershell 脚本仍会给出安全提示

发布于 2025-01-09 05:13:46 字数 707 浏览 0 评论 0原文

我正在尝试运行我编写的 Powershell Cmdlet。

它存储在映射到 Z:\... 的网络驱动器上。

我已在管理员模式下启动 Powershell 并将执行策略设置为 Unrestricted

我已在 Cmdlet 及其调用的每个脚本上运行 Unblock-File

我使用绝对路径或以 .\ 开头的相对路径来调用 Cmdlet。

但是,制表符补全仍然不适用于我的 Cmdlet 参数,并且我仍然收到此安全警告:

Security warning
Run only scripts that you trust. While scripts from the internet can be useful, this script
can potentially harm your computer. If you trust this script, use the Unblock-File cmdlet to
allow the script to run without this warning message. Do you want to run <file-name>?
[D] Do not run [R] Run once [S] Suspend [?] Help (default is “D”):

我做错了什么?

I am trying to run a Powershell Cmdlet that I wrote.

It is stored on a network drive mapped to Z:\....

I have launched Powershell in administrator mode and set the execution policy to Unrestricted.

I have run Unblock-File on my Cmdlet, and every script that it calls.

I am calling my Cmdlet either with its absolute path, or with a relative path beginning with .\.

But still, tab completion is not working for my Cmdlet's parameters, and I still get this security warning:

Security warning
Run only scripts that you trust. While scripts from the internet can be useful, this script
can potentially harm your computer. If you trust this script, use the Unblock-File cmdlet to
allow the script to run without this warning message. Do you want to run <file-name>?
[D] Do not run [R] Run once [S] Suspend [?] Help (default is “D”):

What am I doing wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

回忆那么伤 2025-01-16 05:13:46

就我而言,答案是 Windows 配置为将网络驱动器视为公共互联网上的位置。

解决方案是启动 Internet 选项 控制面板,导航到安全 选项卡,然后添加我的脚本所在的网络共享(例如,\\networkshare)到本地 Intranet 安全区域。

之后,制表符补全可以与我的 Cmdlet 参数一起正常工作,并且脚本可以在没有任何安全警告的情况下执行。

The answer, in my case, is that Windows was configured to regard the network drive as a location on the public internet.

The solution was to launch the Internet Options control panel, navigate to the Security tab, and add the network share where my scripts were located (eg, \\networkshare) to the Local intranet security zone.

Afterwards, the tab completion worked correctly with my Cmdlet's parameters, and the script could execute without any security warning.

_失温 2025-01-16 05:13:46

设置 Intranet 站点:包括在 GPO 中启用的所有网络路径 (UNC)。计算机配置>管理模板> Windows 组件 >互联网浏览器>安全页面

Set the Intranet Sites: Include all network paths (UNCs) to Enabled in a GPO. Computer Config > Admin Templates > Windows Components > Internet Explorer > Security Page

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文