7

I have a Powershell script written in the version 1.0. In this existing old script I need the facility to get the latest code of a project from TFS. I have TFS client on the machine and that lets me use the TFS command line. I have created the TFS command line comments to get the latest from TFS. These commands run successfuly from the command propmt.

Now the I need to include these TFS commands in my old poweshell script. I need to know if this is doable? If yes then how.

Thanks.

Enrico Campidoglio
  • 56,676
  • 12
  • 126
  • 154
user2193894
  • 83
  • 1
  • 1
  • 4

1 Answers1

12

One option is to run the TF.exe program with the necessary arguments from within your PowerShell script, as you would with any other executable:

PS> & "$env:ProgramFiles\Microsoft Visual Studio 10.0\Common7\IDE\TF.exe" @("workspace", "/new", "WS1", "/noprompt", "/login:foo,bar", "/collection:baz/tfs")

Or you could use the TFS PowerShell cmdlets included in the TFS Power Tools:

PS> Add-PSSnapin Microsoft.TeamFoundation.PowerShell 
PS> Get-TfsChangeset -Latest -Server "http://mytfsserver"
Enrico Campidoglio
  • 56,676
  • 12
  • 126
  • 154
  • Thanks Enrico. I would go with the option 1. I have the tfs commands ready. As I am very new to powershell, I am wondering how do I put those in the powershell script. Say this is my command to create a workspace "%ProgramFiles%\Microsoft Visual Studio 10.0\Common7\IDE\TF.exe" workspace /new WS1 /noprompt /login:xxxx,xxxx /collection:http://xxxx/tfsxxx How do I put this is powershell script. Please advise. – user2193894 Jul 11 '13 at 09:09
  • 1
    Thanks much. A little change in the syntax, it expects '/new' & 'ws1' seperated by comma PS> & "$env:ProgramFiles\Microsoft Visual Studio 10.0\Common7\IDE\TF.exe" @("workspace", "/new", "WS1", "/noprompt", "/login:foo,bar", "/collection:baz/tfs") – user2193894 Jul 11 '13 at 11:16