I need some help with how to clone all projects in my TFS 2015 (Update 3) collection at once (git). I found this powershell script below for a newer version, and I tried changing to API version from 4.0 to 2.0 but then it gets the error "Method invocation failed because [System.Management.Automation.PSCustomObject] doesn't contain a method named 'ForEach'."
Having trouble finding an example of how to do this clone in TFS 2015 API or any other way to do it.
$collection = "http://myserver:8080/tfs/DefaultCollection"
$projectsUrl = "$collection/_apis/projects?api-version=4.0"
$projects = Invoke-RestMethod -Uri $projectsUrl -Method Get -UseDefaultCredentials -ContentType application/json
$projects.value.ForEach({
$reposUrl = "$collectionurl/$($_.name)/_apis/git/repositories?api-version=4.0"
$repos = Invoke-RestMethod -Uri $reposUrl -Method Get -UseDefaultCredentials -ContentType application/json
$repos.value.ForEach({
git clone $_.remoteUrl --branch master --single-branch
})
})