Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TFS commands in PowerShell script

Tags:

powershell

tfs

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.

like image 721
user2193894 Avatar asked Jul 11 '13 08:07

user2193894


People also ask

What is TF command?

Flows text to a blank line or to the end of the text. Category: Text Editing, Line Command.

What does the command @() mean in PowerShell?

In PowerShell V2, @ is also the Splat operator. PS> # First use it to create a hashtable of parameters: PS> $params = @{path = "c:\temp"; Recurse= $true} PS> # Then use it to SPLAT the parameters - which is to say to expand a hash table PS> # into a set of command line parameters.


1 Answers

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"
like image 68
Enrico Campidoglio Avatar answered Oct 24 '22 00:10

Enrico Campidoglio