【发布时间】:2021-06-10 15:27:21
【问题描述】:
我很担心,因为我无法弄清楚我发布的目标机器任务(v1.0 和 2.0)上的 powershell 会发生什么。 每次我运行任务时,它都会向我抛出错误:
AuthorizationManager check failed. ---> System.Management.Automation.PSSecurityException: AuthorizationManager check failed. ---> System.Management.Automation.Host.HostException: A command that prompts the user failed because the host program or the command type does not support user interaction. The host was attempting to request confirmation with the following message: 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 \\server\c$\Program Files\exampleps.ps1?
我知道这可能与执行策略有关,所以这是我迄今为止尝试解决问题的方法:
- 我进入远程服务器并为管理员关闭了 IE 增强安全性,因为运行此脚本的服务帐户是 admin
- Shift+右键单击 powershell 以作为服务帐户运行并将执行策略从远程签名更改为绕过。在 32 位和 64 位 powershell 中执行此操作。绕过设置为本地计算机和当前用户
- 将 \server\c$\Program Files\exampleps.ps1 添加到 Internet 选项下的受信任站点
我曾尝试 google 和 stackoverflow 类似的问题,这些都是我发现的。
更新
在尝试了上述所有 3 种方法后,即使我尝试直接在控制台中运行 ps 脚本,安全警告仍然出现。由于某些原因,绕过执行策略没有启动。 --我能够在控制台中运行它而没有警告,但是,tfs 任务仍然失败
我真的很沮丧,我希望社区中的任何人都可以在这方面给我一些指导。
非常感谢。
【问题讨论】:
-
你能试试看运行 unblock-file -path "" 会发生什么
-
我确实尝试了 unblock-file -path cmdlet,它允许我在控制台中执行脚本而不会发出警告。但是,发布的远程机器上的powershell任务仍然失败。
-
似乎绕过执行启动了,所以我可以使用服务帐户在控制台中运行 ps 脚本而不会发出警告,但 TFS 发布任务仍然由于同样的原因失败......
标签: powershell tfs azure-devops remote-server