简体   繁体   English

远程 TFS 通过 Powershell 签入

[英]Remote TFS Checkin via Powershell

We currently have a Scheduled Task on each local PC that runs the command "TF.exe /checkin" when triggered remotely using schtasks.我们目前在每台本地 PC 上都有一个计划任务,当使用 schtasks 远程触发时运行命令“TF.exe /checkin”。 this is so that when someone forgets to check-in we have a way to do so remotely.这样一来,当有人忘记签到时,我们可以远程进行。

But we would like to integrate this into a PowerShell script that can be triggered remotely by just entering the computer name but for some reason, it doesn't seem to work.但我们想将其集成到 PowerShell 脚本中,只需输入计算机名称即可远程触发该脚本,但由于某种原因,它似乎不起作用。

This runs fine on the local pc这在本地电脑上运行良好

Invoke-Command -ScriptBlock {& 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\tf.exe' checkin /recursive}

However, when adding -ComputerName it fails to work with the following error.但是,当添加 -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}

Unable to determine the workspace.无法确定工作区。 You may be able to correct this by running 'tf workspaces /collection:TeamProjetCollectionURL'.您可以通过运行“tf workspaces /collection:TeamProjetCollectionURL”来纠正此问题。 +CategoryInfo: NotSpecified (Unable to deter...ColletionUrl'.:string [], Remoteexpection +CategoryInfo: NotSpecified (无法阻止...ColletionUrl'.:string [], Remoteexpection

Any ideas on how to fix this?有想法该怎么解决这个吗? I've already tried /collection:https://tfsserver:port/collectionanme but it doesn't work either我已经尝试过 /collection:https://tfsserver:port/collectionanme 但它也不起作用

Error: Option /collection cannot be used without option /shelveset which is weird as I am not using /shelveset.错误:如果没有选项 /shelveset,则无法使用选项 /collection,这很奇怪,因为我没有使用 /shelveset。

-----Update---- - - -更新 - -

See the image below, before running the powershell script, I had a file checked out on my local pc, then running Enter-PSSession to a remote computer and then running invoke-command still only checked in my local files and not on remote computer.见下图,在运行 powershell 脚本之前,我在本地电脑上签出了一个文件,然后在远程计算机上运行 Enter-PSSession,然后运行 invoke-command 仍然只签入我的本地文件而不是远程计算机上。 在此处输入图像描述 在此处输入图像描述

---update 04/12--- ---更新04/12---

I don't know why it doesn't work same issue "unable to determine the workspace"我不知道为什么它不起作用同样的问题“无法确定工作区” 在此处输入图像描述

You need to specify workspace path on remote session with the following code:您需要使用以下代码在远程 session 上指定工作区路径:

$session = New-PSSession -ComputerName ComputerName
Invoke-Command -Session $session -ScriptBlock { Set-Location D:\workspace}
Enter-PSSession -Session $session

在此处输入图像描述

Then run tf command:然后运行 tf 命令:

Invoke-Command -ScriptBlock {& 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\tf.exe' checkin /recursive}

Entire result:整体结果:

在此处输入图像描述

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM