2

I'm trying to use PowerTools Update-TfsWorkspace, and as the title suggests, it doesn't work.

Example, I have a co-worker check a file into $/Contoso/Dev/Test. In source control, I can see it grayed out, indicating that while it's there, I don't have it downloaded. So I do the following.

C:\TFS\Contoso\Dev> Update-TfsWorkspace -All -Overwrite -Force -Recurse -Item .\Test

The command executes instantly and does nothing. No error output or anything. And it does not get latest. If I go into VS Source Control and manually get latest, it grabs the intended file, though ideally it should tell me all files are up to date. Does anyone have success with this cmdlet or using PowerTools to do a Get Latest operation from Powershell?

user3066571
  • 1,381
  • 4
  • 14
  • 37

1 Answers1

2

Update-TfsWorkspace should be used in powershell script or powershell cmdlet. If you have multiple workspaces, it's may not work.

Try below method:

$tfsCredential = Get-Credential;
$tfsServer = Get-TfsServer -Name "https://tfs.xxx.com:443/tfs/teamproject" -Credential $tfsCredential;;
$tfsws = Get-TfsWorkspace -Server $tfsServer -Computer $hostname -Owner $tfsCredential.UserName;
$tfsPath = $tfsws.GetServerItemForLocalItem($filename);
$prop = Get-TfsItemProperty -Item $tfsPath -Server $tfsServer -Workspace $script:tfsws;
$tfsws.Get(@($tfsPath), [Microsoft.TeamFoundation.VersionControl.Client.VersionSpec]::Parse($prop.VersionLatest,     $script:tfsws.OwnerName)[0], [Microsoft.TeamFoundation.VersionControl.Client.RecursionType]::Full, [Microsoft.TeamFoundation.VersionControl.Client.GetOptions]::None)

Moreover, to update the workspace you can use tf get command directly. Such as:

C:\TFS\Contoso\Dev> tf get itemspec .\Test /noprompt
PatrickLu-MSFT
  • 49,478
  • 5
  • 35
  • 62
  • I was working in multiple workspaces. The solution was to `cd` into the mapped folder and `tf get`. `tf workfold` helped see the mappings. – JsAndDotNet Sep 25 '17 at 09:30