简体   繁体   English

“目标计算机上的 PowerShell”任务失败,并在 TFS 2017\Azure Dev Ops 中出现错误

[英]“PowerShell on Target Machines” task fails with an error in TFS 2017\Azure Dev Ops

I am trying to run a PowerShell script present on one of the azure server using the "PowerShell on Target Machines" Task in my TFS build definition, but the task fails with the below error.我正在尝试使用 TFS 构建定义中的“目标机器上的 PowerShell”任务运行 azure 服务器之一上存在的 PowerShell 脚本,但任务失败并出现以下错误。

System.Management.Automation.RuntimeException: The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: The specified path, file name, or both are too long. System.Management.Automation.RuntimeException:运行命令停止,因为首选项变量“ErrorActionPreference”或公共参数设置为停止:指定的路径、文件名或两者都太长。 The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.完全限定的文件名必须少于 260 个字符,目录名必须少于 248 个字符。 ---> --->

I have copied the script in F drive but it still gives path too long error, not able to find any solution for the same.我已将脚本复制到 F 驱动器中,但它仍然给出路径太长的错误,无法找到任何解决方案。

Does anyone know what would be the reason?有谁知道是什么原因?

目标机器任务上的 PowerShell 屏幕截图

Added script code as well for reference,还添加了脚本代码以供参考,

GetLatestDebugOutput.ps1获取最新调试输出.ps1

$DebugBuildOutput = "F:\Drops\econNextGen\SecurityScan\19.0"
$Dest = "F:\Drops\econNextGen\SecurityScan\Debug Build Output"


Remove-Item "$Dest\*" -Recurse -Force

#Code to Copy Common-App Debug Build
$Dir= $DebugBuildOutput + "\econNextGen-Common-App-Debug\"
$Latest = Get-ChildItem -Path $Dir | Sort-Object LastAccessTime -Descending | Select-Object -First 1
$FolderPath= $Dir +$Latest.Name 
Copy-Item -Path $FolderPath $Dest –Recurse -force


#Code to Copy Main-App Debug Build
$Dir= $DebugBuildOutput + "\econNextGen-MAIN-APP-Debug\"
$Latest = Get-ChildItem -Path $Dir | Sort-Object LastAccessTime -Descending | Select-Object -First 1
$FolderPath= $Dir +$Latest.Name 
Copy-Item -Path $FolderPath $Dest –Recurse -force

First suggest you directly RDP to remote target machine and check if you are able to run the same script in it.首先建议您直接 RDP 到远程目标机器并检查您是否能够在其中运行相同的脚本。 This will narrow down if the issue related to your tfs build definition and environment.如果与您的 tfs 构建定义和环境相关的问题,这将缩小范围。

For environment, make sure you have met all prerequisites of this PowerShell on Target Machines task .对于环境,请确保您已满足此PowerShell on Target Machines 任务的所有先决条件 And you have qualified powershell version installed.并且您已经安装了合格的 powershell 版本。

Actually the error message is pretty straight forward, and so is the key point you should pay attention to: make sure you're not using paths that are too long or using an invalidly path.实际上,错误消息非常简单,您应该注意的关键点也是如此:确保您没有使用太长的路径或使用无效的路径。 If apply for all folder and files.如果申请所有文件夹和文件。

Besides, try starting the build with diagnostics\debug enabled with system.debug=true and see if you can get any meaningful output for future troubleshooting.此外,尝试使用system.debug=true 启用的 diagnostics\debug 开始构建,看看是否可以获得任何有意义的 output 以供将来故障排除。

暂无
暂无

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

相关问题 针对不同AD域中的计算机的TFS“目标计算机上的Powershell”任务 - TFS 'Powershell on Target Machines' task for machines in different AD domain 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 TFS2017:在远程计算机上使用代理或Powershell中的PSRemote任务 - TFS2017: Use PSRemote from agent or Powershell on Remote Machines task 可以在x86模式下执行“目标计算机上的TFS PowerShell”任务吗? - Can the TFS PowerShell on Target Machines task execute in x86 mode? 目标计算机上的 PowerShell -TFS 任务,在远程服务器中更改执行策略后安全警告仍然存在 - PowerShell on Target Machines -TFS task, Security Warning persists after changing execution policy in remote server Azure 管道“目标机器上的 PowerShell”发布任务启动 Selenium 网格集线器,阻塞管道 - Azure Pipelines "PowerShell on target Machines" Release Task that starts a Selenium Grid Hub, blocks the pipeline 在 Azure Dev Ops 代理上安装 Az 2.8.0 Powershell 模块 - Installing Az 2.8.0 Powershell Module on Azure Dev Ops agent Azure Dev Ops Pipeline 任务(Load Runner Enterprise - Azure Dev Ops Pipeline task (Load Runner Enterpri Azure DevOps 任务内联脚本与 powershell 不会因错误而导致任务失败 - Azure DevOps task inline script with powershell does not fails the task on error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM