0

I am unable to run any of the PowerShell cmdlets provided with TFS 2013 Power Tools against a Team Services account. Problematic commands include Get-TfsItemHistory and Get-TfsChangeset. These work fine with non-hosted instances of TFS but not Team Services. I can successfully connect to Team Services using tf.exe and tfpt.exe. My script is shown below together with the exception that is thrown. Can these commands be used with Team Services and if so what am I doing wrong? Thanks.

#my Team Services credentials:
$Username = "myname@live.com"
$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

Error generated:

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
Esther Fan - MSFT
  • 8,276
  • 4
  • 27
  • 25
  • I just tried with you code at my side with my VSTS/VSO account, but didn't see any issue, the change-set can be got successfully. The error you provided occured when "Get-TfsChangeset", is there any error occur during $tfsCollection.Authenticate()? I also added the powershell script I used before to get the changeset for your reference. – Eddie Chen - MSFT Aug 01 '16 at 01:43

1 Answers1

0

Add my powershell script for your reference:

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
Eddie Chen - MSFT
  • 29,708
  • 2
  • 46
  • 60
  • I get exactly the same behaviour. The inclusion of the Add-PSSnapin statement does not change the result in my particular case because I load it as part of my powershell profile (not shown above). – undertherope Aug 01 '16 at 17:27
  • Authentication works fine. Interestingly, I can access the required data using Powershell if I bypass `Microsoft.TeamFoundation.Powershell` and use the `Microsoft.TeamFoundation.VersionControl.Client` assembly instead. This approach however is a lot involved and I would prefer to avoid. – undertherope Aug 01 '16 at 17:36