Accessing TFS from Powershell
-
21 Şubat 2012 Salı 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
- Düzenleyen Samuel_zhang 21 Şubat 2012 Salı 08:59
Tüm Yanıtlar
-
23 Şubat 2012 Perşembe 06:30Moderatör
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
- Yanıt Olarak İşaretleyen Samuel_zhang 24 Şubat 2012 Cuma 02:36
-
24 Şubat 2012 Cuma 02:36
- Yanıt Olarak İşaretleyen Samuel_zhang 24 Şubat 2012 Cuma 02:49
-
24 Şubat 2012 Cuma 02:39
up up- Yanıt Olarak İşaretleyen Samuel_zhang 24 Şubat 2012 Cuma 02:41
-
28 Şubat 2012 Salı 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
-
24 Nisan 2012 Salı 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
- Düzenleyen it_kris 24 Nisan 2012 Salı 06:16
-
01 Ekim 2012 Pazartesi 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?