如何为Get-TfsItemHistory和Add-TfsPendingChange等命令使用不同的凭据? [英] How do I use different credentials for commands like Get-TfsItemHistory and Add-TfsPendingChange?

查看:79
本文介绍了如何为Get-TfsItemHistory和Add-TfsPendingChange等命令使用不同的凭据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个不在域上的虚拟机,所以当我使用它时,它将无法访问tfs服务器,因为凭据是针对本地计算机的。  如何使用Get-TfsItemHistory和Add-TfsPendingChange等命令来处理不同的
凭据?  如果我没有使用tf.exe命令,它会要求提供凭据,或者将使用我正在调用该命令的工作区的凭据。  我想与powershell版本有类似的结果。


我已经尝试过使用Invoke-Command,但在使用-Credential开关时,它正在进行远程登录,并且远程登录到本地计算机不在域上,因此不起作用。


我试图使用所述的策略
here
,但是当我跑:


 Add-Type -AssemblyName" Microsoft.TeamFoundation.Client,Version = 11.0.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a" 

我收到错误:

 Add-Type:无法添加类型。无法找到程序集"Microsoft.TeamFoundation.Client,Version = 11.0.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a"。 
在行:1 char:1
+ Add-Type -AssemblyName" Microsoft.TeamFoundation.Client,Version = 11.0.0.0,Cultu ...
+ ~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo         :ObjectNotFound:(Microsoft.TeamF ... 03f5f7f11d50a3a:String)[Add-Type],Exception
    + FullyQualifiedErrorId:ASSEMBLY_NOT_FOUND,Microsoft.PowerShell.Commands.AddTypeCommand

Add-Type:无法添加类型。缺少一个或多个必需的程序集。
在行:1 char:1
+ Add-Type -AssemblyName" Microsoft.TeamFoundation.Client,Version = 11.0.0.0,Cultu ...
+ ~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo         :InvalidData :( :) [Add-Type],InvalidOperationException
    + FullyQualifiedErrorId:ASSEMBLY_LOAD_ERRORS,Microsoft.PowerShell.Commands.AddTypeCommand

关于如何使用powershell中的tfs获取不同凭据的任何想法?


谢谢,



A
$




I不要介意将帖子标记为"建议作为答案",但不要将其标记为"已回答"。如果我是OP,我将决定帖子是否真的回答了我的帖子。谢谢。

解决方案

嗨ADRIAN,


根据我的研究,没有办法为TFS管理单元命令指定凭证(例如Get-TfsItemHistory)


另一种方法是使用TFS API。对于无法添加类型的错误:


它将程序集加载到GAC中,因此如果组件中没有GAC符合条件,它无法加载。简单的方法是你可以使用Add-Type -Path命令,例如:

 


Tfs2015AssembliesPath =" XXX \ Microsoft Visual Studio 14.0 \ Common7 \IDE \CommonExtensions\Microsoft \TeamFoundation \Team Explorer"
Add-Type -Path"


Tfs2015AssembliesPath\Microsoft.TeamFoundation.Client.dll"

问候


Starain


I have a VM that is not on the domain, so when I use that, it will not be able to access the tfs server because the credentials are for the local computer.  How do I get commands like Get-TfsItemHistory and Add-TfsPendingChange to work with different credentials?  If I were t use the tf.exe command, it asks for credentials or will use the credentials that are for that workspace that I'm invoking the command on.  I would like to have similar results with the powershell version.

I've already tried to use Invoke-Command, but when using the -Credential switch, it is doing a remote login, and the remote login to the local computer is not on the domain, so that doesn't work.

I've tried to use the tactics stated here, but when I run:

Add-Type –AssemblyName "Microsoft.TeamFoundation.Client, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"

I get the error:

Add-Type : Cannot add type. The assembly 'Microsoft.TeamFoundation.Client, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' could not be found.
At line:1 char:1
+ Add-Type –AssemblyName "Microsoft.TeamFoundation.Client, Version=11.0.0.0, Cultu ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Microsoft.TeamF...03f5f7f11d50a3a:String) [Add-Type], Exception
    + FullyQualifiedErrorId : ASSEMBLY_NOT_FOUND,Microsoft.PowerShell.Commands.AddTypeCommand

Add-Type : Cannot add type. One or more required assemblies are missing.
At line:1 char:1
+ Add-Type –AssemblyName "Microsoft.TeamFoundation.Client, Version=11.0.0.0, Cultu ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Add-Type], InvalidOperationException
    + FullyQualifiedErrorId : ASSEMBLY_LOAD_ERRORS,Microsoft.PowerShell.Commands.AddTypeCommand

Any ideas as to how to use the tfs from powershell for different credentials?

Thanks,

A


I don't mind someone marking a post as "Proposed as answer", but DO NOT mark it as "Answered". If I am the OP, I will decide if a post actually answers my post or not. Thank you.

解决方案

Hi A D R I A N,

Based on my research, there isn’t the way to specify credential for the command of TFS snapin (e.g. Get-TfsItemHistory)

The other way is use TFS API. For the error of cannot add type:

It loads the assembly in GAC, so if there isn’t the assembly in the GAC meet the condition, it can’t load. The simple way is that you could use Add-Type –Path command, for example:


Tfs2015AssembliesPath="XXX\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer" Add-Type -Path "


Tfs2015AssembliesPath\Microsoft.TeamFoundation.Client.dll"

Regards

Starain


这篇关于如何为Get-TfsItemHistory和Add-TfsPendingChange等命令使用不同的凭据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆