Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/Apps/AppManagement.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
$appIDs = @(
'Iv1.f26b61bc99e69405'
)
$orgs = Get-GitHubAppInstallableOrganization -Enterprise 'msx'
$orgs = Get-GitHubOrganization -Enterprise 'msx'
foreach ($org in $orgs) {
foreach ($appID in $appIDs) {
Install-GitHubAppOnEnterpriseOrganization -Enterprise msx -Organization $org.login -ClientID $appID -RepositorySelection all
Expand Down
2 changes: 1 addition & 1 deletion examples/Apps/EnterpriseApps.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ filter Install-GithubApp {
)

process {
$installableOrgs = Get-GitHubAppInstallableOrganization -Enterprise $Enterprise -Debug -Verbose
$installableOrgs = Get-GitHubOrganization -Enterprise $Enterprise -Debug -Verbose
$orgs = $installableOrgs | Where-Object { $_.login -like $organization }
foreach ($org in $orgs) {
foreach ($appIDitem in $AppID) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@
[System.Nullable[int]] $PerPage,

# The context to run the command in. Used to get the details for the API call.
# Can be either a string or a GitHubContext object.
[Parameter()]
[object] $Context = (Get-GitHubContext)
[Parameter(Mandatory)]
[object] $Context
)

begin {
Expand All @@ -49,13 +48,11 @@
}

Invoke-GitHubAPI @inputObject | ForEach-Object {
Write-Output $_.Response
[GitHubOrganization]::new($_.Response)
}
}

end {
Write-Debug "[$stackPath] - End"
}
}

#SkipTest:FunctionTest:Will add a test for this function in a future PR
45 changes: 30 additions & 15 deletions src/functions/public/Organization/Get-GitHubOrganization.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,27 @@
.EXAMPLE
Get-GitHubOrganization

List organizations for the authenticated user.
List all organizations for the authenticated user.

.EXAMPLE
Get-GitHubOrganization -Username 'octocat'

List public organizations for the user 'octocat'.
List public organizations for a specific user.

.EXAMPLE
Get-GitHubOrganization -All -Since 142951047

List organizations, starting with PSModule.
List all organizations made after an ID.

.EXAMPLE
Get-GitHubOrganization -Name 'PSModule'

Get the organization 'PSModule'.
Get a specific organization.

.EXAMPLE
Get-GitHubOrganization -Enterprise 'msx'

Get the organizations belonging to an Enterprise.

.OUTPUTS
GitHubOrganization
Expand All @@ -36,13 +41,13 @@
https://psmodule.io/GitHub/Functions/Organization/Get-GitHubOrganization
#>
[OutputType([GitHubOrganization])]
[CmdletBinding(DefaultParameterSetName = '__AllParameterSets')]
[CmdletBinding(DefaultParameterSetName = 'List all organizations for the authenticated user')]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', 'All', Justification = 'Required for parameter set')]
param(
# The organization name. The name is not case sensitive.
[Parameter(
Mandatory,
ParameterSetName = 'NamedOrg',
ParameterSetName = 'Get a specific organization',
ValueFromPipeline,
ValueFromPipelineByPropertyName
)]
Expand All @@ -51,27 +56,34 @@
# The handle for the GitHub user account.
[Parameter(
Mandatory,
ParameterSetName = 'NamedUser',
ParameterSetName = 'List public organizations for a specific user',
ValueFromPipelineByPropertyName
)]
[Alias('User')]
[string] $Username,

# The Enterprise slug to get organizations from.
[Parameter(
Mandatory,
ParameterSetName = 'Get the organizations belonging to an Enterprise',
ValueFromPipelineByPropertyName
)]
[string] $Enterprise,

# List all organizations. Use '-Since' to start at a specific organization ID.
[Parameter(
Mandatory,
ParameterSetName = 'AllOrg'
ParameterSetName = 'List all organizations on the tenant'
)]
[switch] $All,

# A organization ID. Only return organizations with an ID greater than this ID.
[Parameter(ParameterSetName = 'AllOrg')]
[Parameter(ParameterSetName = 'List all organizations on the tenant')]
[int] $Since = 0,

# The number of results per page (max 100).
[Parameter(ParameterSetName = 'AllOrg')]
[Parameter(ParameterSetName = 'UserOrg')]
[Parameter(ParameterSetName = '__AllParameterSets')]
[Parameter(ParameterSetName = 'List all organizations on the tenant')]
[Parameter(ParameterSetName = 'List all organizations for the authenticated user')]
[System.Nullable[int]] $PerPage,

# The context to run the command in. Used to get the details for the API call.
Expand All @@ -89,13 +101,16 @@

process {
switch ($PSCmdlet.ParameterSetName) {
'NamedOrg' {
'Get a specific organization' {
Get-GitHubOrganizationByName -Name $Name -Context $Context
}
'NamedUser' {
'List public organizations for a specific user' {
Get-GitHubUserOrganization -Username $Username -Context $Context
}
'AllOrg' {
'Get the organizations belonging to an Enterprise' {
Get-GitHubAppInstallableOrganization -Enterprise $Enterprise -Context $Context
}
'List all organizations on the tenant' {
Get-GitHubAllOrganization -Since $Since -PerPage $PerPage -Context $Context
}
default {
Expand Down