[Microsoft.TeamFoundation.Client.TeamFoundationServerFactory] ​​:: GetServer指定凭据

时间:2013-02-12 17:32:33

标签: powershell command-line tfs tfs2010 powershell-v2.0

我有以下代码连接到TFS:

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

如何指定我的登录名并在此处作为参数传递?默认情况下,它使用脚本运行的帐户,但我想设置不同的

1 个答案:

答案 0 :(得分:2)

签出this blog post - TeamFoundationServerFactory API不支持自定义凭据。您应该使用TeamFoundationServer类构造函数。

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