Functions/Public/Get-BitBucketCloudRepository.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
function Get-BitBucketCloudRepository {
    [CmdletBinding()]
    param(
        [Parameter()]
        [ValidateNotNullOrEmpty()]
        [string]
        $Team
    )

    if (-Not $PSBoundParameters.ContainsKey('Team')) {
        $Team = (Get-BitBucketCloud).Team
    }

    $Values = Invoke-BitBucketCloudApi -Path "/repositories/$Team"

    foreach ($Repo in $Values) {
        [pscustomobject]@{
            Name    = $Repo.name
            Owner   = $Repo.owner.username
            Project = $Repo.project.name
            Size    = $Repo.size
            Private = $Repo.is_private
            Created = $Repo.created_on
        }
    }
}