AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 528238
Accepted
Stephane
Stephane
Asked: 2013-08-03 05:21:35 +0800 CST2013-08-03 05:21:35 +0800 CST 2013-08-03 05:21:35 +0800 CST

什么会导致不考虑 Powershell 执行策略?

  • 772

我们的基础架构中有许多用于各种任务的 powershell 脚本,从用户登录到支持技术人员模拟用户上下文。

这些脚本集中在我们的文件服务器上(通过 DFS),以便于管理。其中一些在登录时运行,一些通过已发布的 Citrix 应用程序运行。

我们为整个域和所有用户应用了一项策略,将 Powershell 执行策略设置为“无限制”,以便脚本可以从文件服务器运行。

这对于登录脚本(至少到目前为止)非常有效,但对于稍后运行的脚本(通常通过已发布的应用程序,但在使用终端服务和完整桌面时同样适用),结果不一致:一些用户可以运行脚本很好,在 powershell 控制台中总是提示一些让脚本运行。

我找不到任何可能导致这种行为的东西,而且确实不一致:如果我手动启动 powershell 并运行get-executionpolicy,我被告知当前策略是unrestricted. 然而,如果在同一个会话中,我尝试通过调用的程序运行脚本,powershell <script file name> <parameters>我会在脚本运行之前得到提示。

什么可能导致这种行为?

powershell
  • 1 1 个回答
  • 2170 Views

1 个回答

  • Voted
  1. Best Answer
    jbsmith
    2013-08-03T06:11:54+08:002013-08-03T06:11:54+08:00

    我猜你看到的提示是这样的:

    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
    

    如果您运行“get-help about_execution_policies”,您将看到“无限制”的行为定义为:

     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.
    

    即使设置为无限制,PowerShell 也会提示您运行它认为是从 Internet 下载的脚本——这可能包括从 UNC 路径调用的脚本。您可以通过调整计算机上的 Internet Explorer 安全区域(是的,真的)和/或使用 caspol.exe 在系统上配置 .NET 代码访问安全策略来调整行为。

    如果这实际上是您看到的提示,这里有一些有用的链接:

    http://blogs.msdn.com/b/powershell/archive/2007/05/06/running-scripts-downloaded-from-the-internet.aspx

    http://www.leeholmes.com/blog/2008/07/24/powershell-execution-policies-in-standard-images/

    http://powertoe.wordpress.com/2010/08/10/corporate-powershell-module-repository-part-1-design-and-infrastructure/

    • 4

相关问题

  • 资源锁和电源外壳

  • 脚本 - 如何断开远程桌面会话?

  • 如何限制向通讯组发送到外部地址?

  • Powershell对值与数组的作用不同?

  • Windows Powershell Vim 键绑定

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve