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

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

    $Values = Invoke-BitBucketCloudApi -ApiVersion 1.0 -Path "/groups/$Team"

    foreach ($Item in $Values) {
        [pscustomobject]@{
            Name       = $Item.name
            Permission = $Item.permission
            AutoAdd    = $Item.auto_add
            Owner      = $Item.owner.username
            Members    = $Item.members.username
            Slug       = $Item.slug
        }
    }
}