简体   繁体   English

目标计算机上的 PowerShell -TFS 任务,在远程服务器中更改执行策略后安全警告仍然存在

[英]PowerShell on Target Machines -TFS task, Security Warning persists after changing execution policy in remote server

I am pulling my hairs as I could not figure out what happens in powershell on target machine task (v1.0 and 2.0) in my release.我正在拉扯我的头发,因为我无法弄清楚我发布的目标机器任务(v1.0 和 2.0)中 powershell 中发生了什么。 every time I run the task, it throws me the error:每次我运行任务时,它都会向我抛出错误:

 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?

I understand this may relate to execution policy, so this is what I have done so far trying to solve the issue:我知道这可能与执行策略有关,所以这是我迄今为止试图解决这个问题所做的:

  1. I went in the remote server and turned off IE enhanced security for admins, as the service account to run this script is admin我进入远程服务器并关闭了管理员的 IE 增强安全性,因为运行此脚本的服务帐户是管理员
  2. Shift+Right-click powershell to run as service account and changed execution policy from remotesigned to bypass. Shift+右键单击 powershell 以作为服务帐户运行,并将执行策略从远程签名更改为绕过。 performed this action in both 32 and 64bit powershell.在 32 位和 64 位 powershell 中执行此操作。 Bypass was set to local machine and current user旁路设置为本地机器和当前用户
  3. Added the \server\c$\Program Files\exampleps.ps1 to trusted site under internet options将 \server\c$\Program Files\exampleps.ps1 添加到 Internet 选项下的受信任站点

I have tried to google and stackoverflow similar questions and these are what I found.我试图谷歌和stackoverflow类似的问题,这些是我发现的。

Update更新

After trying all 3 methods above, even when I try to run the ps script directly in console, the security warning still shows up.在尝试了上述所有 3 种方法后,即使我尝试直接在控制台中运行 ps 脚本,安全警告仍然出现。 For some reasons, the bypass execution policy doesn't kick in. --I was able to run it in console without warnings, however, tfs task still failed由于某些原因,绕过执行策略没有启动。-我能够在控制台中运行它而没有警告,但是,tfs 任务仍然失败

I am really frustrated and I hope anyone in the community can give me some guidance on the this.我真的很沮丧,我希望社区中的任何人都可以给我一些指导。

Much appreciated.非常感激。

Please try the following ways to see if they can work:请尝试以下方法,看看它们是否可以工作:

  1. Use the "Bypass" Execution Policy Flag使用“绕过”执行策略标志

    PowerShell.exe -ExecutionPolicy Bypass -File \server\c$\Program Files\exampleps.ps1
  2. Read Script from the File and Pipe to PowerShell Standard In从文件中读取脚本和 Pipe 到 PowerShell 标准输入

    Get-Content \server\c$\Program Files\exampleps.ps1 | PowerShell.exe -noprofile -
  3. Use the Invoke-Expression Command使用调用表达式命令

    Get-Content \server\c$\Program Files\exampleps.ps1 | Invoke-Expression
  4. Use the "Unrestricted" Execution Policy Flag使用“无限制”执行策略标志

    PowerShell.exe -ExecutionPolicy UnRestricted -File \server\c$\Program Files\exampleps.ps1

There also are few other ways you can try.您还可以尝试其他几种方法。 To view more details, you can reference to " 15 Ways to Bypass the PowerShell Execution Policy ".要查看更多详细信息,您可以参考“ 绕过 PowerShell 执行策略的 15 种方法”。

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

相关问题 针对不同AD域中的计算机的TFS“目标计算机上的Powershell”任务 - TFS 'Powershell on Target Machines' task for machines in different AD domain 可以在x86模式下执行“目标计算机上的TFS PowerShell”任务吗? - Can the TFS PowerShell on Target Machines task execute in x86 mode? “目标计算机上的 PowerShell”任务失败,并在 TFS 2017\Azure Dev Ops 中出现错误 - “PowerShell on Target Machines” task fails with an error in TFS 2017\Azure Dev Ops TFS2017:在远程计算机上使用代理或Powershell中的PSRemote任务 - TFS2017: Use PSRemote from agent or Powershell on Remote Machines task TFS在目标计算机上构建“ PowerShell”步骤失败:如何调试? - TFS Build “PowerShell on Target Machines” Step Fails: How to debug? 目标机器上的 PowerShell 在 TFS 2018 发布管道中失败 - PowerShell on Target Machines Fails in TFS 2018 Release Pipeline 目标机器上的TFS2015 Powershell-在发布过程中设置变量/在远程服务器上找到可用端口 - TFS2015 Powershell on Target Machine - Set a variable in the release process / Find a free port on a remote server 通过Powershell和任务执行进行远程登录 - Remote logon through Powershell and task execution 绕过 PowerShell 中的执行策略时是否存在任何安全风险? - is there any Security risks when bypassing the Execution Policy in PowerShell? Powershell:执行政策 - Powershell : Execution Policy
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM