Andriy Kuzmych
Andriy Kuzmych

Reputation: 193

[Microsoft.TeamFoundation.Client.TeamFoundationServerFactory]::GetServer specify credentials

I have following code for connection to TFS:

$tfs = [Microsoft.TeamFoundation.Client.TeamFoundationServerFactory]::GetServer($serverName)

How I can specify my login and pass as parameter here? By default it use account under which the script is running, but I would like to set different one

Upvotes: 0

Views: 930

Answers (1)

latkin
latkin

Reputation: 16792

Check out this blog post - the TeamFoundationServerFactory API is not designed to support custom credentials. You should use the TeamFoundationServer class constructor, instead.

$creds = Get-Credential
$server = New-Object Microsoft.TeamFoundation.Client.TeamFoundationServer $url,$creds.GetNetworkCredential()

Upvotes: 2

Related Questions