【问题标题】:Powershell script not authenticating TFS connectionPowershell 脚本未对 TFS 连接进行身份验证
【发布时间】:2018-11-01 08:17:45
【问题描述】:

我在将 powershell 连接到 VTFS(云基础)时遇到问题。我的脚本已经工作多年了。不知道发生了什么,除了我从微软运行的更新,我认为这是问题所在。此脚本在 Microsoft 更新之前于 4 月运行,没有出现任何问题。

I get the following error trying to connect, which generally makes a popup appear for my credentials to Online  Visual Studios.

 if ( (Get-PSSnapin -Name Microsoft.TeamFoundation.PowerShell) -eq $null )
    {
        Add-PSSnapin Microsoft.TeamFoundation.PowerShell
    }

 # Variables - CHECK EACH TIME
    [string] $tfsServerLocationPath = "https://name.visualstudio.com/DefaultCollection"
    [string] $ProjectLocationToSearch = "$/Project/blabla/"
    [string] $outputFile = "c:\temp\RetrievedFiles.txt"
    [string] $dateRange = "D2018-04-18 00:00:00Z~"
    [bool]   $openOutputFile = $true 
    $AutoDeployDir = "$/Project/blabla/"
    $deployDirectory = "C:\Temp\ReleaseTest\DeployFiles\" 
    $tfsCollection = New-Object -TypeName  Microsoft.TeamFoundation.Client.TfsTeamProjectCollection -ArgumentList $tfsServerLocationPath
    $tfsVersionControl = $tfsCollection.GetService([Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer])


**AFTER THIS LINE IS WHEN THE ERROR APPEARS.**
    [Microsoft.TeamFoundation.Client.TfsTeamProjectCollection] $tfs = get-tfsserver  $tfsServerLocationPath 


    get-tfsserver : Key not valid for use in specified state.
At line:31 char:67
+ [Microsoft.TeamFoundation.Client.TfsTeamProjectCollection] $tfs = get-tfsserver  ...
+                                                                   ~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Get-TfsServer], CryptographicException
    + FullyQualifiedErrorId : GetTfsServer,Microsoft.TeamFoundation.PowerTools.PowerShell.GetTf 
   sServerCommand

Thank You in Advance.

【问题讨论】:

  • 您以前更改过帐户密码吗?你使用的是什么客户端? VS 2015 还是 VS 2017 或其他?
  • Andy - 我正在使用 powerShell 和 tfs 的 snapin。我以管理员身份从 PowerShell ISE 运行此脚本,该脚本刚刚在 4 月运行,没有出现问题。我每月运行一次此脚本以检索发布文件以进行部署。四月之后,我运行了 Microsoft 更新。我查看了我的更新历史记录,并没有看到任何似乎是罪魁祸首的东西。这在几年前发生在我身上,我不记得我需要运行什么包/msi 来解决这个问题。
  • 操作系统版本是多少?明确指定凭证怎么样:$tfs = get-tfsserver $tfsServerLocationPath -credential $credential -all。如果仍然无法解决问题,您能否在此处分享完整的脚本以进行故障排除?
  • Andy 我在 Windows 7 上已应用最新更新。请保持我的一切正常。我上面发布的脚本部分是从顶部到失败的部分,如图所示。脚本的其余部分与问题无关。该部分应该执行并且应该显示登录凭据的弹出窗口。我们使用的 TFS 是基于云的,而不是本地的。您提供的代码不起作用。我很欣赏这个建议。我得到同样的错误。
  • 这里是错误 get-tfsserver :密钥在指定状态下无效。在 line:17 char:67 + [Microsoft.TeamFoundation.Client.TfsTeamProjectCollection] $tfs = get-tfsserver ... + ~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [ Get-TfsServer], Cryptograph hicException + FullyQualifiedErrorId : GetTfsServer,Microsoft.TeamFoundation.PowerTools .PowerShell.GetTfsServerCommand

标签: powershell tfs


【解决方案1】:

哇——我的幸运日,感谢和我有同样问题的所有人。这是修复。我不得不删除这个注册表项。 HKEY_CURRENT_USER\Software\Microsoft\VSCommon\12.0\ClientServices\TokenStorage。

我在以下帖子中找到了这里。

http://blogs.msdn.microsoft.com/dstfs/2014/01/10/

【讨论】:

  • 嗯,这意味着你安装了 VS 2013 作为客户端。很高兴知道您已经解决了这个问题,您可以Accept it as an Answer,这可能对阅读此主题的其他社区成员有所帮助。
猜你喜欢
  • 1970-01-01
  • 2018-11-02
  • 2019-02-25
  • 2016-11-05
  • 2015-09-23
  • 2017-09-18
  • 1970-01-01
  • 2022-08-21
  • 2017-12-23
相关资源
最近更新 更多