【问题标题】:[Microsoft.TeamFoundation.Client.TeamFoundationServerFactory]::GetServer specify credentials[Microsoft.TeamFoundation.Client.TeamFoundationServerFactory]::GetServer 指定凭据
【发布时间】:2013-01-28 02:25:21
【问题描述】:

我有以下连接到 TFS 的代码:

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

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

【问题讨论】:

    标签: powershell command-line tfs powershell-2.0


    【解决方案1】:

    查看this blog post - TeamFoundationServerFactory API 并非旨在支持自定义凭据。您应该改用 TeamFoundationServer 类构造函数。

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

    【讨论】:

      猜你喜欢
      • 2012-08-05
      • 1970-01-01
      • 1970-01-01
      • 2021-03-10
      • 2020-10-26
      • 1970-01-01
      • 2018-02-09
      • 1970-01-01
      相关资源
      最近更新 更多