0
votes

We currently have a Scheduled Task on each local PC that runs the command "TF.exe /checkin" when triggered remotely using schtasks. 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.

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.

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'. +CategoryInfo: NotSpecified (Unable to deter...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

Error: Option /collection cannot be used without option /shelveset which is weird as I am not using /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. enter image description here enter image description here

---update 04/12---

I don't know why it doesn't work same issue "unable to determine the workspace" enter image description here

1

1 Answers

0
votes

You need to specify workspace path on remote session with the following code:

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

enter image description here

Then run tf command:

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:

enter image description here