Accessing TFS from Powershell
-
Tuesday, February 21, 2012 8:58 AM
I am a new to PowerShell and I am trying to get all source code from TFS using Powershell scirpt. Unfortunately I am falling.
I do have VS2010 and Powertools installed on my local machine and can access the TFS server(also 2010)
I am running the script from my local machine and have following lines:
[Reflection.Assembly]::Load(“Microsoft.TeamFoundation.Client, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”);
$hostName = "http://192.168.1.201:8080/tfs"
$user = "admin"
$password = ConvertTo-SecureString "abc" -AsPlainText -Force$credential = New-Object System.Management.Automation.PSCredential ($user, $password)
$tfs = get-tfsserver -name $hostName -credential $credential -all
and I receive the following error as below:
Get-TfsServer : TF31002: Unable to connect to this Team Foundation Server: http://192.168.1.201:8080/tfs.
Team Foundation Server Url: http://192.168.1.201:8080/tfs.
Possible reasons for failure include:
- The name, port number, or protocol for the Team Foundation Server is incorrect.
- The Team Foundation Server is offline.
- The password has expired or is incorrect.
Technical information (for administrator):
The request failed with HTTP status 404: Not Found.
Technical information (for administrator):
The request failed with HTTP status 404: Not Found.
At C:\Users\Samuel\Desktop\Perl Script\Untitled14.ps1:18 char:21
+ $tfs = get-tfsserver <<<< -name $hostName -credential $credential
+ CategoryInfo : InvalidArgument: (:) [Get-TfsServer], TeamFoundationS...ilableException
+ FullyQualifiedErrorId : GetTfsServer,Microsoft.TeamFoundation.PowerTools.PowerShell.GetTfsServerCommandThanks for any help given!!!
The Seven Deadly Sins
- Edited by Samuel_zhang Tuesday, February 21, 2012 8:59 AM
All Replies
-
Thursday, February 23, 2012 6:30 AMModerator
Hi Samuel_zhang,
Thank you for your question.
I am trying to involve someone familiar with this topic to further look at this issue. There might be some time delay. Appreciate your patience.
Thank you for your understanding and support.
Best Regards,
Lily Wu [MSFT]
MSDN Community Support | Feedback to us
- Marked As Answer by Samuel_zhang Friday, February 24, 2012 2:36 AM
-
Friday, February 24, 2012 2:36 AM
- Marked As Answer by Samuel_zhang Friday, February 24, 2012 2:49 AM
-
Friday, February 24, 2012 2:39 AM
up up- Marked As Answer by Samuel_zhang Friday, February 24, 2012 2:41 AM
-
Tuesday, February 28, 2012 6:21 AM
Hi Samuel
Try changing your URL to include the collection name:
($hostName= http://server:8080/tfs/collectionname) and remove the -all
Thanks,
Brad
This posting is provided "AS IS" with no warranties, and confers no rights
-
Tuesday, April 24, 2012 6:14 AM
Hi,
[string]$username=" username"
$password= ConvertTo-SecureString 'password' -AsPlainText -Force
[string]$tfsURL="http://"+$server_path+":8080/tfs"
$credential = New-Object System.Management.Automation.PSCredential ($username, $password)$tfsConnection = new-object Microsoft.TeamFoundation.Client.TfsConfigurationServer $tfsURL, $credential
$tfsConnection.Authenticate()on this line: $tfs = get-tfsserver -name $hostName -credential $credential -all you invoke the tf.exe from visual studio and this is the reason why you are not able to connect on TFS using powershell. You should work with TFS API not with tf.exe
- Edited by it_kris Tuesday, April 24, 2012 6:16 AM
-
Monday, October 01, 2012 6:50 PM
Am I the only person who sees a problem with putting you password in to a script as clear text?
Surely there is a better solution than that?

