Akin
Akin

Reputation: 149

Powershell: Using Copy-Item to copy a file from TFS Server to another destination

I have the command

Copy-Item -literalPath $file.ServerItem $destinationPath -recurse -force

where

$file.ServerItem (path to file on tfs server that we want to copy)= "$/TFSServer/MyPath/ToTheFile.vb"

and

$destinationPath (test server path where file should be copied to) = "\104server\MyPath\ToTheFile.vb"

I get the error

Copy-Item: Cannot find path '$/TFSServer/MyPath/ToTheFile.vb' because it does not exist.

This file exists. Please, do you have any ideas?

Upvotes: 0

Views: 1731

Answers (1)

Keith Hill
Keith Hill

Reputation: 202062

You can't copy directly from a TFS server path spec $/TeamProjectName/path. There is no TFS Provider that I'm aware of. You need to create a mapping of the TFS source to a local directory. Do a tf get . /r on that local dir to get all the source files. Then whereever you see $/TFSServer in a ServerItem path, replace it with your local directory name. Say you put the files in C:\TFSServer, then create your source path like so:

$srcPath = $file.ServerItem.Replace("$","C:")

Upvotes: 2

Related Questions