Skip to content

Commit a929092

Browse files
[+] Added function to call for pending organization invitations
1 parent 75f7827 commit a929092

3 files changed

Lines changed: 40 additions & 3 deletions

File tree

PSGithubUtils/PSGithubUtils.psd1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
RootModule = 'PSGithubUtils.psm1'
1313

1414
# Version number of this module.
15-
ModuleVersion = '0.2.0'
15+
ModuleVersion = '0.2.2'
1616

1717
# Supported PSEditions
1818
# CompatiblePSEditions = @()
@@ -69,7 +69,7 @@
6969
# NestedModules = @()
7070

7171
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
72-
FunctionsToExport = 'Get-GithubToken', 'New-OrganizationMember'
72+
FunctionsToExport = 'Get-GithubToken', 'New-OrganizationMember', 'Get-PendingOrganizationInvitations'
7373

7474
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
7575
CmdletsToExport = @()

PSGithubUtils/PSGithubUtils.psm1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ if ($PSVersionTable.PSVersion.Major -lt 7){
2525
}
2626

2727
Add-Type -Path $securityLibPath
28-
Add-Type -TypeDefinition (Get-Content -Path ".\lib\Private\BasicPasswordFinder.cs" -Raw) -ReferencedAssemblies @($securityLibPath)
28+
Add-Type -TypeDefinition (Get-Content -Path "$PSScriptRoot\lib\Private\BasicPasswordFinder.cs" -Raw) -ReferencedAssemblies @($securityLibPath)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<#
2+
.SYNOPSIS
3+
Lists all pending organization invitations.
4+
5+
.DESCRIPTION
6+
Implements the API call documented within https://docs.github.com/en/free-pro-team@latest/rest/orgs/members?apiVersion=2022-11-28#list-pending-organization-invitations.
7+
8+
.PARAMETER Token
9+
The Token retrieved using the Get-GithubToken. The Application used during retrieval has to have permissions to the organization.
10+
11+
.PARAMETER Organization
12+
The name of the organization.
13+
14+
.EXAMPLE
15+
Get-PendingOrganizationInvitations -Token $token -Organization "adesso-Copilot"
16+
#>
17+
function Get-PendingOrganizationInvitations {
18+
param(
19+
[Parameter(Mandatory)]
20+
[string]
21+
$Token,
22+
[Parameter(Mandatory)]
23+
[string]
24+
$Organization
25+
)
26+
27+
$headers = @{
28+
Authorization = "Bearer $Token"
29+
Accept = "application/vnd.github+json"
30+
"X-GitHub-Api-Version" = "2022-11-28"
31+
}
32+
33+
$url = "https://api.github.com/orgs/$Organization/invitations"
34+
$response = Invoke-RestMethod -Uri $url -Headers $headers -Method GET
35+
36+
return $response
37+
}

0 commit comments

Comments
 (0)