【问题标题】:Why does TFS Authentification fail from remote PowerShell session?为什么远程 PowerShell 会话中的 TFS 身份验证失败?
【发布时间】:2012-08-05 15:16:44
【问题描述】:

当我直接在机器上运行以下 PowerShell 脚本时

Add-Type -Path "C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\ReferenceAssemblies\v2.0\Microsoft.TeamFoundation.VersionControl.Client.dll"

$basePath = "http://magv-dev-tfs:8080/tfs/MccCollection"
[Microsoft.TeamFoundation.Client.TeamFoundationServerFactory]::GetServer($basePath)

我得到一个对象,其中设置了字段 AuthenticatedUserName、AuthenticatedUserDisplayName、AuthenticatedUserIdentity。

当我在同一台机器上的其他机器上使用相同的凭据在远程 PowerShellTab 中运行相同的脚本时,这 3 个字段是 emply:

AuthenticatedUserName           : 
AuthenticatedUserDisplayName    : 
AuthenticatedUserIdentity       : 
Uri                             : http://my-tfs:8080/tfs/mcccollection
TimeZone                        : System.CurrentSystemTimeZone
InstanceId                      : 
Name                            : my-tfs\MccCollection
Credentials                     : System.Net.SystemNetworkCredential
Culture                         : de-DE
SessionId                       : 7c76a150-f681-4b3c-9b0d-2836a3a5a908
ClientCacheDirectoryForInstance : 
HasAuthenticated                : False
TfsTeamProjectCollection        : magv-dev-tfs\MccCollection

编辑:

至少我找到了解决How to use [Microsoft.TeamFoundation.Client.TeamFoundationServerFactory]::GetServer with credential from Powershell的工作

【问题讨论】:

  • 我刚刚碰到了这个问题;我希望找到解决方法。

标签: powershell tfs powershell-remoting


【解决方案1】:

在调用命令调用中添加 -credential 参数?

【讨论】:

    【解决方案2】:

    当您使用 Visual Studio TFS 时,PowerShell 可以访问您在连接到项目时注册的连接。 RegisteredTfsConnections 提供对已注册连接的访问​​权限,因此您不必费心将凭据放入代码中。

    下面的 sn-p 连接到一个 TFS 服务器,并返回一个 WorkItem。

    [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Client") [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.WorkItemTracking.Client") $regProjCollection = [Microsoft.TeamFoundation.Client.RegisteredTfsConnections]::GetProjectCollection("tfs2010\TFS2010-MyCollection") $tfsTeamProjCollection = [Microsoft.TeamFoundation.Client.TfsTeamProjectCollectionFactory]::GetTeamProjectCollection($regProjCollection) $ws = $tfsTeamProjCollection.GetService([type]"Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore") $ws.GetWorkItem(2525)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-07-23
      • 2015-04-24
      • 1970-01-01
      • 1970-01-01
      • 2020-07-19
      • 2018-12-06
      • 1970-01-01
      • 2018-02-14
      相关资源
      最近更新 更多