Accessing TFS from Powershell
-
Dienstag, 21. Februar 2012 08:58
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
- Bearbeitet Samuel_zhang Dienstag, 21. Februar 2012 08:59
Alle Antworten
-
Donnerstag, 23. Februar 2012 06:30Moderator
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
- Als Antwort markiert Samuel_zhang Freitag, 24. Februar 2012 02:36
-
Freitag, 24. Februar 2012 02:36
- Als Antwort markiert Samuel_zhang Freitag, 24. Februar 2012 02:49
-
Freitag, 24. Februar 2012 02:39
up up- Als Antwort markiert Samuel_zhang Freitag, 24. Februar 2012 02:41
-
Dienstag, 28. Februar 2012 06:21
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
-
Dienstag, 24. April 2012 06:14
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
- Bearbeitet it_kris Dienstag, 24. April 2012 06:16
-
Montag, 1. Oktober 2012 18:50
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?

