1

What I'm trying to do should be simple - I want to get information for a single TFS workspace (in this case named the same as the computer name), and have that information returned via text - not via prompt window (it's my understanding this is what the /noprompt option is for). I am using the "workspace" command, and according to the official documentation (https://learn.microsoft.com/en-us/vsts/tfvc/workspace-command), it's not 100% clear this is supported.

Note:

  • I have tf.exe from Visual Studio 2017 and 2015 installed, and the 2015 Power Tools, but am preferring the 2017 client.
  • I've read the TF Workspaces question, and view this as something else - I specifically want the information about a single workspace (for a PowerShell script).
ryanwebjackson
  • 1,017
  • 6
  • 22
  • 36
  • What makes you think it's not supported? And what's' your exact question? Using the Workspace command or the Workspaces command from tf is what you should use unless you want to use the VersionControlServer object directly from PowerShell. – jessehouwing Oct 31 '17 at 15:49
  • I didn't say it wasn't supported; it's just not clear if it is, in the documentation. The workspace or workspaces commands don't give me what I want, at least in the format I'm looking for (text details for a single workspace). – ryanwebjackson Oct 31 '17 at 16:49
  • Do you have a link to information about the VersionControlServer object? I don't think I've used it. – ryanwebjackson Oct 31 '17 at 16:49

2 Answers2

0

The /noprompt option of tf.exe don't allow you to view details.

It allows you to create a new workspace or edit existing one, without the dialog.

Hamid Shahid
  • 4,486
  • 3
  • 32
  • 41
0

You can use the tfs client object model to query local workspaces. You can get the local workspaces through the workstation object https://msdn.microsoft.com/en-us/library/microsoft.teamfoundation.versioncontrol.client.workstation(v=vs.120).aspx

And you can use the version control server object to query additional details, fetch files, change the mapping etc https://msdn.microsoft.com/en-us/library/microsoft.teamfoundation.versioncontrol.client.versioncontrolserver(v=vs.120).aspx

This blog explains how to load the right assemblies, it references the 12.0 object model, I'd reccomend using the latest nuget packages instead. https://www.google.nl/amp/s/alistairbmackay.wordpress.com/2016/02/01/manipulating-tfs-with-powershell-part-1-connecting/amp/

Latest object model: https://www.nuget.org/packages/Microsoft.TeamFoundationServer.ExtendedClient/

jessehouwing
  • 106,458
  • 22
  • 256
  • 341
  • I haven't tested it yet, but the Workstation.GetLocalWorkspaceInfo(string) method should give me what I want. The blog post you listed I've seen, but didn't realize the VersionControlServer object was what I needed. Also, it's assembly loading code didn't work for me, and I'm not sure why (I've figured that out since then though). – ryanwebjackson Nov 02 '17 at 16:42
  • Is there a difference between the TFS ExtendedClient you mention, and the libraries/dlls included with a current Visual Studio (2017) installation? Also, if it is the way to go, is the NuGet package manager console that comes with VS the "recommended" approach? Looks like there are a couple other ways to use it via the command line -- https://learn.microsoft.com/en-us/nuget/guides/install-nuget – ryanwebjackson Nov 02 '17 at 16:49
  • Nuget is preferred since 2015. Do not rely on existing VS installs or GAC. And package the assemblies with your script and don't rely on the package mgmnt console – jessehouwing Nov 02 '17 at 18:01