I am trying to create a Powershell script with Visual Studio 2019 that accesses a particular Team Foundation Server 2015 team project and one of its branches. The goal is to return the names of files that have been either created or modified within a specific time period. To accomplish this, I am under the impression that I must filter for the .CreationTime and .LastWriteTime properties.
I have successfully accessed the project collection with the [Microsoft.TeamFoundation.Client] API, but fail to access individual team projects when using the version control repository instantiation [Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer]. Authentication has been ensured but no vcs methods recognize the repository paths. (I purposely omitted the assembly declarations from the code below.)
$tfsCollectionURI =[System.Uri]'http://tfs.infosys.com:8080/tfs/collection/'
$projectsCollection = [Microsoft.TeamFoundation.Client.TfsTeamProjectCollectionFactory]::GetTeamProjectCollection($tfsCollectionURI)
if($projectsCollection.HasAuthenticated)
{
$vcs = $projectsCollection.GetService([Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer])
}
$projectPath = 'http://tfs.infosys.com:8080/tfs/collection/
project/_git/Enterprise'
$vcs.GetAllTeamProjects($true)
$vcs.GetTeamProject('EHBs')
$vcs.GetItems($projectPath)
According to your shared code, you are trying to get the wrong projectPath.
http://tfs.infosys.com:8080/tfs/collection/project/_git/Enterprise
This seems like a url in web portal of git repo.
However you code are used for TFVC version control. The project path should be something as $/MyFirstProject/Main-branch2.0-child1
You could use this rest api below to find Git Repos in a team project:
GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}?api-version=4.1
And you could use GET Invoke-RestMethod to execute REST API in Powershell, for PowerShell REST API Programming, please refer to the following link: