Why does TFS Authentification fail from a remote PowerShell session?

When I run the following PowerShell script directly on the machine

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) 

I get objects with fields AuthenticatedUserName, AuthenticatedUserDisplayName, AuthenticatedUserIdentity.

When I run the same script in a remote PowerShellTab from another computer on the same computer using the sam e credentials, these 3 fields have the following meanings:

 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 

Edit:

At least I found a job. How to use [Microsoft.TeamFoundation.Client.TeamFoundationServerFactory] :: GetServer with credentials from Powershell

+4
source share
2 answers

Add -credential argument to invoke invocation invocation?

+1
source

When you use Visual Studio TFS, PowerShell can access the connections that you registered when connecting to your project. RegisteredTfsConnections provides access to registered connections, so you don’t have to worry about entering your credentials into the code.

The following snippet connects to the TFS server and returns a 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) 
+1
source

All Articles