0
votes

Good day. I created a tfs-workspace on a remote computer, and worked with it in Visual Studio. All fine, check-ins and check-outs work correctly. Today I decided to automate some tasks, but Powershell tools throws various error during working with this workspace.

I checked scripts' work on local folder - all fine. I've tried to use variations of UNC paths (FileSystem::myPath), Resolve-Path, Get-ChildItem, Get-TfsChildItem, but all of it doesn,t work. tf checkout even can't determine the workspace.

Are there any variants to work with a workspace on remote computer in PowerShell?

P.S. TFS, VS, TFPT of 13th version. P.P.S. I can't use "net use" or it's analogue.

P.P.P.S Commands and results:

Microsoft.PowerShell.Core\FileSystem::\\srv-tfsmain\D$\NetWorkspace\MyUser\Test> tf checkout 15
tf : Unable to determine the workspace. You may be able to correct this by running 'tf workspaces /collection:TeamProjectCollectionUrl'.


Microsoft.PowerShell.Core\FileSystem::\\srv-tfsmain\D$\NetWorkspace\MyUser\Test> Add-TfsPendingChange -edit 15
Add-TfsPendingChange : The filename, directory name, or volume label syntax is incorrect. $path


Microsoft.PowerShell.Core\FileSystem::\\srv-tfsmain\D$\NetWorkspace\MyUser\Test> Add-TfsPendingChange -edit (Resolve-Path 15)
Add-TfsPendingChange : Cannot bind parameter 'Item'. Cannot convert the "Microsoft.PowerShell.Core\FileSystem::\\srv-tfsmain\D$\NetWorkspace\MyUser\Test\15" value of type "System.Management.Automation.PathInfo" to type "Microsoft.TeamFoundation.PowerTools.PowerShell.QualifiedItemSpec".

Upd 1. The error was in the incorrect path: Workspace was mapped to \srv-tfsmain\NetWorkspace\MyUser\Test, and i used command in \srv-tfsmain\D$\NetWorkspace\MyUser\Test. After correcting path, tf works fine, but

Add-TfsPendingChange -edit

doesn't work with any form of UNC path.

1
Please post your scripts with related errors.Jan Zahradník
imho, your path seems undefined to powershell, I tried to search for similar strings and found out this thread, can you try to use convert-path to determine the real path of the remote workspace path of yours, link hereBeytan Kurt
@Beytan Kurt , I tried to use Convert-Path. It returns fileName in \\server\D$\path\fileName mode. Add-tfsPendingChange -edit doesn't work with such parameter too.Oxoron

1 Answers

2
votes

It cannot work that way. The TFS concept of workspace implies that you give command the same path you defined in the workspace. So if on PC01 you defined workspace WRK01 that maps $/MyProject to C:\wrk01, you must run the command locally with C:\wrk01; \\PC01\c$\work01 or else won't work.

Using Powershell, you can use a remote session to run the cmdlets locally (but they must be installed on the target machine), see Enter-PSSession to start.