security - 忽略 'Security Warning' 从命令行运行脚本

标签 security powershell

我正在尝试从我信任的共享文件夹执行脚本:

PowerShell -file "\\server\scripts\my.ps1"

但我收到安全警告,必须按“R”才能继续

Security Warning Run only scripts that you trust. While scripts from the Internet can be useful, this script can potentially harm your computer. Do you want to run \server\scripts\my.ps1? [D] Do not run [R] Run once [S] Suspend [?] Help (default is "D"): d

我可以忽略这个警告吗?我想要的伪代码是:

PowerShell -IGNORE_SECURITY_WARNING -file "\\server\scripts\my.ps1"

最佳答案

这在"PowerShell Execution Policies in Standard Images" on Lee Holmes' Blog中有所涉及。和 "PowerShell’s Security Guiding Principles" on the Windows Power Shell Blog .

摘要 有些机器将 UNC 路径视为严重的互联网,因此 PowerShell 将它们视为远程文件。您可以在这些服务器上禁用此功能 (UncAsIntranet = 0,),或者将远程计算机添加到您的可信主机。

如果您不想执行任何操作,PowerShell v2 支持 -ExecutionPolicy 参数,它可以完全满足您的伪代码的需要。 PowerShell -ExecutionPolicy 绕过 -File (...)

关于security - 忽略 'Security Warning' 从命令行运行脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/728143/

相关文章:

bash - 如果物理机死机,Docker rm 不会删除我的容器

php - 这个登录系统安全吗?

regex - 使用 Powershell 打印出与 RegEx 匹配的代码行号

string - 使用 PowerShell sls (Select-String) vs grep vs findstr

powershell - PowerShell “Advance”解析以基于日志文件计算组件安装时间

security - Heroku 应用程序在 VPN 上调用外部 Web 服务

android - 将 API 请求限制为仅我自己的移动应用程序

java - 使用HTTPS客户端向服务器的440端口发送请求

powershell - 在 Powershell 中导入类似 `import <module> as <alias>` 的模块

powershell - 如何按目录路径的一部分排除文件