Disconnect files from TFS 2010 using powershell

I only want to check the path using powershell, and also check this path in a minute on Team Foundation Server.

How can i do this?

I installed tfs power tools on my server.

+6
source share
5 answers

You do not need power tools. Just use the tf.exe command line utility that ships with Visual Studio with TFS Team Explorer. tf edit <file> /noprompt to check and tf checkin <file> /comment:$comment /noprompt to check. Take a look at using the command line on tf.exe for more information tf /? and tf checkin /? . You will need to set up a PowerShell session using Path to tf.exe. This is usually done by VS vars commands. But you should just add to the following path: $PATH += "${VS110COMNTOOLS}..\Ide" .

+9
source

Here is a function that checks if snapin is installed. If you installed powertools, it uses this, otherwise it uses the tf.exe command line tf.exe

 function checkout-file([string] $file) { "Checking out $file" if ((Get-PSSnapin -Name Microsoft.TeamFoundation.PowerShell -ErrorAction SilentlyContinue) -eq $null ) { Add-PsSnapin Microsoft.TeamFoundation.PowerShell -ErrorAction SilentlyContinue if ((Get-PSSnapin -Name Microsoft.TeamFoundation.PowerShell -ErrorAction SilentlyContinue) -eq $null ) { #try to check out the code using command line tf.exe &"C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\TF.exe" checkout $file | Out-Null } else{ #checkout the file using snapin Add-TfsPendingChange -Edit $file | Out-Null } }else{ #checkout the file using snapin Add-TfsPendingChange -Edit $file | Out-Null } } 
+5
source

If you have Power Tools for powershell installed. You don't need the Path, as Kate mentions, part of the command aliases for tf for the full path of tf.exe. So just use the tf.exe command line link here , and all this should work if you have powershell batch files installed.

You must make sure your powershell installed them using this command, although

  Add-PSSnapin Microsoft.TeamFoundation.PowerShell 
+2
source

This is my decision:

 $tf = &"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\tf.exe" checkout C:\setup\folder /recursive $tf | Out-null 
+2
source

Another option is to use wild-card if you are trying to process several files in one command without selecting other files or without sorting them.

  tf.exe undo AssemblyInfo* /recursive tf.exe checkout AssemblyInfo* /recursive #changes files tf.exe checkin AssemblyInfo* /recursive 
0
source

All Articles