【发布时间】:2021-03-09 00:53:35
【问题描述】:
我们目前在每台本地 PC 上都有一个计划任务,当使用 schtasks 远程触发时运行命令“TF.exe /checkin”。这样一来,当有人忘记签到时,我们可以远程进行。
但我们希望将其集成到 PowerShell 脚本中,只需输入计算机名称即可远程触发该脚本,但由于某种原因,它似乎不起作用。
这在本地电脑上运行良好
Invoke-Command -ScriptBlock {& 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\tf.exe' checkin /recursive}
但是,当添加 -ComputerName 时,它无法工作并出现以下错误。
Invoke-Command -ComputerName *ComputerName* -ScriptBlock {& 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\tf.exe' check-in /recursive}
无法确定工作区。您可以通过运行“tf workspaces /collection:TeamProjetCollectionURL”来纠正此问题。 +CategoryInfo: NotSpecified (无法阻止...ColletionUrl'.:string [], Remoteexpection
关于如何解决这个问题的任何想法?我已经尝试过 /collection:https://tfsserver:port/collectionanme 但它也不起作用
错误:如果没有选项 /shelveset,则无法使用选项 /collection,这很奇怪,因为我没有使用 /shelveset。
-----更新----
见下图,在运行 powershell 脚本之前,我在本地电脑上签出了一个文件,然后在远程计算机上运行 Enter-PSSession,然后运行 invoke-command 仍然只签入我的本地文件而不是远程计算机。
---更新04/12---
【问题讨论】:
标签: powershell tfs azure-devops