Created
August 26, 2015 10:36
-
-
Save RafPe/bdbfb1d3bd8d4a6df2c9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$tfsurl = 'https://tfs.someservername:8088/tfs/SomeAwesomeCollection' | |
$username = 'administrator' | |
$domain = 'MyCompany' | |
$password = 'Password1' | |
# Create URI | |
$tfs_uri = [System.Uri]::new( $tfsurl ) | |
# Create server object | |
$_tfs_server = [Microsoft.TeamFoundation.Client.TfsTeamProjectCollectionFactory]::GetTeamProjectCollection($tfs_uri, $false, $fale) | |
# Create credentials object and assign them to server | |
$cred = New-Object System.Net.NetworkCredential($username,$password,$domain) | |
$_tfs_server.Credentials = $cred | |
# Authenticate | |
try | |
{ | |
$_tfs_server.EnsureAuthenticated() | |
return $_tfs_server | |
} | |
catch | |
{ | |
throw 'Error while tryint to authenticate to TFS server' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment