Locked Accessing TFS from Powershell

  • 21 Februari 2012 8: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.GetTfsServerCommand

    Thanks for any help given!!!


    The Seven Deadly Sins


Semua Balasan

  • 23 Februari 2012 6:30
    Moderator
     
     Jawab

    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

    • Ditandai sebagai Jawaban oleh Samuel_zhang 24 Februari 2012 2:36
    •  
  • 24 Februari 2012 2:36
     
     Jawab

    Thanks Lily_Wu


    The Seven Deadly Sins

    • Ditandai sebagai Jawaban oleh Samuel_zhang 24 Februari 2012 2:49
    •  
  • 24 Februari 2012 2:39
     
     Jawab
    up  up
    • Ditandai sebagai Jawaban oleh Samuel_zhang 24 Februari 2012 2:41
    •  
  • 28 Februari 2012 6: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 April 2012 6: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


    • Diedit oleh it_kris 24 April 2012 6:16
    •  
  • 01 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?