Which kind of credentials must I provide, to get this working
$tfsServer = [Microsoft.TeamFoundation.Client.TeamFoundationServerFactory]::GetServer($basePath,$credential)
I tried:
$credential = New-Object System.Management.Automation.PsCredential($user,$password)
and
$credential = New-Object System.Net.NetworkCredential($user, $password, $domane)
and always got
Für "GetServer" und die folgende Argumenteanzahl kann keine Überladung gefunden werden: "2".
Bei Zeile:18 Zeichen:86
+ $tfsServer = [Microsoft.TeamFoundation.Client.TeamFoundationServerFactory]::GetServer <<<< ($basePath,$credential)
+ CategoryInfo : NotSpecified: (:) [], MethodException
+ FullyQualifiedErrorId : MethodCountCouldNotFindBest
I want to use
TeamFoundationServerFactory.GetServer Method (String, ICredentialsProvider)
cf. http://msdn.microsoft.com/en-us/library/bb136201%28v=vs.80%29.aspx
The background is, that I want to call this in a remote PowerShell session and for some reason, I do not understand
$tfsServer = [Microsoft.TeamFoundation.Client.TeamFoundationServerFactory]::GetServer($basePath)
yields
"TF30063: You are not authorized to access mytfs\MccCollection."
you are calling the new-object incorrectly to create the credential
The following code works:
When executed for the first time,
$tfsServer.EnsureAuthenticated()
throws an error, but afterwards it is authenticated.The
TeamFoundationServerFactory
expects aICredentialsProvider
implementation as @Berns_k shows in his answer. If you already have the credentials you should use a different way of instantiating yourTfsTeamProjectCollection
:or in powershell:
That way you don't need to create a Credential Provider and you should not get any error on your first call to
EnsureAuthenticated
.