2016-07-30 14 views
0

TFS 2013 Power Toolsで提供されるPowerShellコマンドレットをTeam Servicesアカウントに対して実行することはできません。問題のあるコマンドには、Get-TfsItemHistoryGet-TfsChangesetが含まれます。これらは、TFSのホストされていないインスタンスでは正常に動作しますが、Team Servicesでは動作しません。 tf.exetfpt.exeを使用してTeam Servicesに正常に接続できます。 スクリプトがスローされた例外とともに以下に示されています。 これらのコマンドをTeam Servicesで使用することはできますか?もしそうなら、私は間違っていますか?おかげさまで Microsoft.TeamFoundation.PowerTools.PowerShellコマンドレットを使用してVisual Studio Team Services(VSO)をクエリする方法

#my Team Services credentials: 
$Username = "[email protected]" 
$tfsPath = "https://myname.visualstudio.com/" 
$passwordFile=".\ps-password.pwd" 

# read passsword from file 
# NOTE: password previously stored within file using command: 
# read-host -prompt Password -assecurestring | 
# convertfrom-securestring | 
# out-file ps-password.pwd -ErrorAction Stop 
if (!(test-path $passwordFile)) 
{ 
    throw [System.IO.FileNotFoundException] "$passwordFile" 
} 
$Password = Get-Content "$passwordFile" | ConvertTo-SecureString 

$creds = New-Object -typename System.Management.Automation.PSCredential -ArgumentList $Username,$Password 

$tfsServer = New-Object System.Uri("$tfsPath") 

$tfsCollection = New-Object Microsoft.TeamFoundation.Client.TfsTeamProjectCollection($tfsServer,$creds) 
$tfsCollection.Authenticate() 

# $tfsCollection | show-object # NOTE: content of collection looks good when viewed 

# PROBLEM COMMANDS: 
Get-TfsChangeset -latest -server $tfsCollection 
Get-TfsItemHistory "$/" -Server $tfsCollection -Version "D2010-01-01~D2016-08-01" -Recurse -IncludeItem 

エラーが発生:

Get-TfsChangeset : The filename, directory name, or volume label syntax is incorrect. 
At ~\myScript.ps1:30 char:1 
+ Get-TfsChangeset -latest -server $tfsCollection 
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    + CategoryInfo   : NotSpecified: (:) [Get-TfsChangeset], IOException 
    + FullyQualifiedErrorId : System.IO.IOException,Microsoft.TeamFoundation.PowerTools.PowerShell.GetTfsChangesetCommand 
+0

何か問題が見えても、変更セットは正常に取得できます。 "Get-TfsChangeset"を実行したときに指定したエラーが発生しました。$ tfsCollection.Authenticate()中にエラーが発生しましたか?あなたが参照するためにチェンジセットを取得するために私が前に使用したPowerShellスクリプトも追加しました。 –

答えて

0

はあなたの参照のための私のPowerShellスクリプトを追加します。私はちょうど「私のVSTS/VSOアカウントで私の側で、あなたのコードを試みたが、didnの

Add-PSSnapin Microsoft.TeamFoundation.PowerShell 

$tfsPath = "https://xxxxxx.visualstudio.com/" 

[Microsoft.TeamFoundation.Client.TfsTeamProjectCollection] $tfs = get-tfsserver $tfsPath 

Get-TfsChangeset -latest -Server $tfs 
Get-TfsItemHistory "$/" -Server $tfs -Version "D2016-07-27~D2016-08-01" -Recurse -IncludeItem 
+0

私はまったく同じ動作をします。 Add-PSSnapinステートメントをインクルードしても、PowerShellプロファイルの一部として読み込むため、私の特別なケースで結果は変わりません(上記には示されていません)。 – undertherope

+0

認証が正常に動作します。興味深いことに、 'Microsoft.TeamFoundation.Powershell'をバイパスし、代わりに' Microsoft.TeamFoundation.VersionControl.Client'アセンブリを使用すると、Powershellを使用して必要なデータにアクセスできます。しかし、このアプローチはかなり関わっており、私は避けたいと考えています。 – undertherope

関連する問題