From f000b67ef02c53e4fb575dc07964c8d1cf976ab4 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Fri, 6 Jun 2025 13:47:00 +0200 Subject: [PATCH 1/4] =?UTF-8?q?=F0=9F=A9=B9[Patch]:=20Remove=20`Get-GitHub?= =?UTF-8?q?AppInstallableOrganization`=20function=20and=20integrate=20its?= =?UTF-8?q?=20functionality=20into=20`Get-GitHubOrganization`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Get-GitHubAppInstallableOrganization.ps1 | 9 +++------ .../public/Organization/Get-GitHubOrganization.ps1 | 11 +++++++++++ 2 files changed, 14 insertions(+), 6 deletions(-) rename src/functions/{public/Apps/GitHub App => private/Apps/GitHub Apps}/Get-GitHubAppInstallableOrganization.ps1 (87%) diff --git a/src/functions/public/Apps/GitHub App/Get-GitHubAppInstallableOrganization.ps1 b/src/functions/private/Apps/GitHub Apps/Get-GitHubAppInstallableOrganization.ps1 similarity index 87% rename from src/functions/public/Apps/GitHub App/Get-GitHubAppInstallableOrganization.ps1 rename to src/functions/private/Apps/GitHub Apps/Get-GitHubAppInstallableOrganization.ps1 index 7b3e271ea..f94b2b2ec 100644 --- a/src/functions/public/Apps/GitHub App/Get-GitHubAppInstallableOrganization.ps1 +++ b/src/functions/private/Apps/GitHub Apps/Get-GitHubAppInstallableOrganization.ps1 @@ -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 { @@ -49,7 +48,7 @@ } Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response + [GitHubOrganization]::new($_.Response) } } @@ -57,5 +56,3 @@ Write-Debug "[$stackPath] - End" } } - -#SkipTest:FunctionTest:Will add a test for this function in a future PR diff --git a/src/functions/public/Organization/Get-GitHubOrganization.ps1 b/src/functions/public/Organization/Get-GitHubOrganization.ps1 index 9dd44759a..beeb67d32 100644 --- a/src/functions/public/Organization/Get-GitHubOrganization.ps1 +++ b/src/functions/public/Organization/Get-GitHubOrganization.ps1 @@ -57,6 +57,14 @@ [Alias('User')] [string] $Username, + # The Enterprise slug to get organizations from. + [Parameter( + Mandatory, + ParameterSetName = 'EnterpriseOrganizations', + ValueFromPipelineByPropertyName + )] + [string] $Enterprise, + # List all organizations. Use '-Since' to start at a specific organization ID. [Parameter( Mandatory, @@ -95,6 +103,9 @@ 'NamedUser' { Get-GitHubUserOrganization -Username $Username -Context $Context } + 'EnterpriseOrganizations' { + Get-GitHubAppInstallableOrganization -Enterprise $Enterprise -Context $Context + } 'AllOrg' { Get-GitHubAllOrganization -Since $Since -PerPage $PerPage -Context $Context } From ba28fefcb924561bd5528d982906d32dee55faa7 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Fri, 6 Jun 2025 13:48:55 +0200 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=A9=B9[Patch]:=20Add=20example=20for?= =?UTF-8?q?=20retrieving=20organizations=20by=20Enterprise=20in=20`Get-Git?= =?UTF-8?q?HubOrganization`=20function?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/functions/public/Organization/Get-GitHubOrganization.ps1 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/functions/public/Organization/Get-GitHubOrganization.ps1 b/src/functions/public/Organization/Get-GitHubOrganization.ps1 index beeb67d32..5fca0473b 100644 --- a/src/functions/public/Organization/Get-GitHubOrganization.ps1 +++ b/src/functions/public/Organization/Get-GitHubOrganization.ps1 @@ -29,6 +29,11 @@ Get the organization 'PSModule'. + .EXAMPLE + Get-GitHubOrganization -Enterprise 'msx' + + Get the organizations belonging to the Enterprise called 'msx'. + .OUTPUTS GitHubOrganization From 9bb20672deebb77e744b0ff58aa19422ddc17c97 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Fri, 6 Jun 2025 14:00:31 +0200 Subject: [PATCH 3/4] =?UTF-8?q?=F0=9F=A9=B9[Patch]:=20Update=20examples=20?= =?UTF-8?q?and=20parameter=20set=20names=20in=20`Get-GitHubOrganization`?= =?UTF-8?q?=20function=20for=20clarity?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Organization/Get-GitHubOrganization.ps1 | 35 +++++++++---------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/src/functions/public/Organization/Get-GitHubOrganization.ps1 b/src/functions/public/Organization/Get-GitHubOrganization.ps1 index 5fca0473b..ca19008c8 100644 --- a/src/functions/public/Organization/Get-GitHubOrganization.ps1 +++ b/src/functions/public/Organization/Get-GitHubOrganization.ps1 @@ -12,27 +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 the Enterprise called 'msx'. + Get the organizations belonging to an Enterprise. .OUTPUTS GitHubOrganization @@ -41,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 )] @@ -56,7 +56,7 @@ # The handle for the GitHub user account. [Parameter( Mandatory, - ParameterSetName = 'NamedUser', + ParameterSetName = 'List public organizations for a specific user', ValueFromPipelineByPropertyName )] [Alias('User')] @@ -65,7 +65,7 @@ # The Enterprise slug to get organizations from. [Parameter( Mandatory, - ParameterSetName = 'EnterpriseOrganizations', + ParameterSetName = 'Get the organizations belonging to an Enterprise', ValueFromPipelineByPropertyName )] [string] $Enterprise, @@ -73,18 +73,17 @@ # 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. @@ -102,16 +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 } - 'EnterpriseOrganizations' { + 'Get the organizations belonging to an Enterprise' { Get-GitHubAppInstallableOrganization -Enterprise $Enterprise -Context $Context } - 'AllOrg' { + 'List all organizations on the tenant' { Get-GitHubAllOrganization -Since $Since -PerPage $PerPage -Context $Context } default { From 0164b86b7b08080fd78d50d27c397d4566978dbb Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Fri, 6 Jun 2025 14:02:09 +0200 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=A9=B9[Patch]:=20Replace=20`Get-GitHu?= =?UTF-8?q?bAppInstallableOrganization`=20with=20`Get-GitHubOrganization`?= =?UTF-8?q?=20in=20app=20management=20examples=20for=20consistency?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/Apps/AppManagement.ps1 | 2 +- examples/Apps/EnterpriseApps.ps1 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/Apps/AppManagement.ps1 b/examples/Apps/AppManagement.ps1 index 041d19f19..677f9e0c3 100644 --- a/examples/Apps/AppManagement.ps1 +++ b/examples/Apps/AppManagement.ps1 @@ -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 diff --git a/examples/Apps/EnterpriseApps.ps1 b/examples/Apps/EnterpriseApps.ps1 index 69de8c402..f06cbfaa7 100644 --- a/examples/Apps/EnterpriseApps.ps1 +++ b/examples/Apps/EnterpriseApps.ps1 @@ -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) {