[英]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:我知道这可能与执行策略有关,所以这是我迄今为止试图解决这个问题所做的:
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:请尝试以下方法,看看它们是否可以工作:
Use the "Bypass" Execution Policy Flag使用“绕过”执行策略标志
PowerShell.exe -ExecutionPolicy Bypass -File \server\c$\Program Files\exampleps.ps1
Read Script from the File and Pipe to PowerShell Standard In从文件中读取脚本和 Pipe 到 PowerShell 标准输入
Get-Content \server\c$\Program Files\exampleps.ps1 | PowerShell.exe -noprofile -
Use the Invoke-Expression Command使用调用表达式命令
Get-Content \server\c$\Program Files\exampleps.ps1 | Invoke-Expression
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.