Powershell – Connect to TFS wiith alternative credentials

In this short post I will just show you how can you connect to your TFS server (from PowerShell) using alternative credentials. As it might be useful when you automate your infra to peform certain task. This script assumes you do have required TFS dlls available on your machine. If not you need to get them and load them on runtime

This is how I load it in a seperate parts of my scripts

        # load the required dll


Here is the script itself …



  1. Getting a Method Invocation failed error:

    PS C:\Windows\system32> $tfs_uri = [System.Uri]::new(‘https://tfs.someservername:8088/tfs/SomeAwesomeCollection’ )
    Method invocation failed because [System.Uri] doesn’t contain a method named ‘new’.
    At line:1 char:1
    + $tfs_uri = [System.Uri]::new( ‘https://tfs.someservername:8088/tfs/SomeAwesomeC …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : MethodNotFound

    any thoughts?

    • Hey James ,

      Can you try following :
      $tfs_uri = [System.Uri]’https://tfs.someservername:8088/tfs/SomeAwesomeCollection

Leave a Reply

Your email address will not be published. Required fields are marked *