Get-TFSGitRepositories.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# Author: Miodrag Milic <miodrag.milic@gmail.com>
# Last Change: 26-Apr-2016.

<#
.SYNOPSIS
    Get the TFS Git repositories
#>

function Get-TFSGitRepositories {
    [CmdletBinding()]
    param ()
    check_credential

    $uri = "$proj_uri/_apis/git/repositories?api-version=" + $tfs.api_version
    Write-Verbose "URI: $uri"

    $params = @{ Uri = $uri; Method = 'Get'}
    $r = invoke_rest $params

    $list = @()
    foreach ($r in $r.value) {
        $b = [pscustomobject]@{
            Raw      = $r
            Id       = $r.id
            Name     = $r.name
            Project  = $r.project.name
        }
        $b.PSObject.TypeNames.Insert(0,'TFS.GitRepository')
        $list += $b
    }

    $list
}