From f897ecc714ccafb2a981583e46c3284e846cb12e Mon Sep 17 00:00:00 2001 From: Cristian Miguel Zangaro Date: Tue, 22 Apr 2025 11:50:39 -0300 Subject: [PATCH] Update invite_members_to_org.ps1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Aaron > Co-authored-by: Andrew > Co-authored-by: Andy > Co-authored-by: Aziz > Co-authored-by: Aziz > Co-authored-by: Aziz > Co-authored-by: Bas > Co-authored-by: Brandon > Co-authored-by: Briana > Co-authored-by: Bryan > Co-authored-by: Cheerag > Co-authored-by: Chris > Co-authored-by: Chris > Co-authored-by: Cloud > Co-authored-by: Coding > Co-authored-by: Craig > Co-authored-by: Daniel > Co-authored-by: Evgeny > Co-authored-by: Gam > Co-authored-by: Garen > Co-authored-by: Garen > Co-authored-by: Gennaro > Co-authored-by: Geoff > Co-authored-by: Georgi > Co-authored-by: Greg > Co-authored-by: Hayato > Co-authored-by: Ivan > Co-authored-by: JD > Co-authored-by: James > Co-authored-by: Jamie > Co-authored-by: Jamie > Co-authored-by: Jamie > Co-authored-by: Jamie > Co-authored-by: Jared > Co-authored-by: Jason > Co-authored-by: Jason > Co-authored-by: Javier > Co-authored-by: Joey > Co-authored-by: Johannes > Co-authored-by: John > Co-authored-by: John > Co-authored-by: John > Co-authored-by: Jon > Co-authored-by: Jon > Co-authored-by: Jonathan > Co-authored-by: Jonathan > Co-authored-by: Justin > Co-authored-by: Jürgen > Co-authored-by: Kayla > Co-authored-by: Kevin > Co-authored-by: Kyle > Co-authored-by: Kyle > Co-authored-by: Kyle > Co-authored-by: Lars > Co-authored-by: Leona > Co-authored-by: Lucas > Co-authored-by: Lukas > Co-authored-by: Mario > Co-authored-by: Martin-Louis > Co-authored-by: Matthew > Co-authored-by: Michael > Co-authored-by: Michael > Co-authored-by: Mike > Co-authored-by: Mike > Co-authored-by: Natalie > Co-authored-by: Nathan > Co-authored-by: Nathan > Co-authored-by: Oscar > Co-authored-by: Pavan > Co-authored-by: Pavan > Co-authored-by: Peter > Co-authored-by: Peter > Co-authored-by: Philip > Co-authored-by: Philippe > Co-authored-by: Pierluigi > Co-authored-by: Prem > Co-authored-by: Ramon > Co-authored-by: Ramon > Co-authored-by: Rowena > Co-authored-by: Ryan > Co-authored-by: Ryan > Co-authored-by: Sarah > Co-authored-by: Sarah > Co-authored-by: Sarah > Co-authored-by: Sebass > Co-authored-by: Sebastian > Co-authored-by: Sijis > Co-authored-by: Stacy > Co-authored-by: Stefan > Co-authored-by: Stefan > Co-authored-by: Stefan > Co-authored-by: Steffen > Co-authored-by: Suriyaa > Co-authored-by: Takafumi > Co-authored-by: Thomas > Co-authored-by: Thomas > Co-authored-by: Tim <<103634854+sn2b@users.noreply.github.com>> Co-authored-by: Tom > Co-authored-by: Tommy > Co-authored-by: Wan > Co-authored-by: Zack > Co-authored-by: brooksClo19 <<51922180+brooksClo19@users.noreply.github.com>> Co-authored-by: bss-mc <<117171930+bss-mc@users.noreply.github.com>> Co-authored-by: bss-mc <> Co-authored-by: dependabot[bot] <<49699333+dependabot[bot]@users.noreply.github.com>> Co-authored-by: djdefi <> Co-authored-by: djdefi <> Co-authored-by: doublemarket <> Co-authored-by: github-actions[bot] <<41898282+github-actions[bot]@users.noreply.github.com>> Co-authored-by: iamdanfox <> Co-authored-by: jefeish <> Co-authored-by: jokram <> Co-authored-by: jonatanblue <> Co-authored-by: k33g <> Co-authored-by: samwiskow <> Co-authored-by: snyk-bot <> Co-authored-by: stoe <> Co-authored-by: tcbyrd <> --- api/powershell/invite_members_to_org.ps1 | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/api/powershell/invite_members_to_org.ps1 b/api/powershell/invite_members_to_org.ps1 index f758dca8b..e8e6e34f3 100644 --- a/api/powershell/invite_members_to_org.ps1 +++ b/api/powershell/invite_members_to_org.ps1 @@ -2,7 +2,7 @@ <# .SYNOPSIS -Batch invite members to an organization +Automates bulk invitations to a GitHub organization by processing usernames or emails from a consumed licenses CSV file. .DESCRIPTION This script runs a batch organization invitation process for a given list of GitHub Enterprise @@ -13,6 +13,20 @@ Enterprise settings > Enterprise licensing page. Users with appropriate permissi the CSV file, edit it in their favorite spreadsheet to select emails to invite, then use this script to invite them to an org. +The script supports both GitHub usernames (handles) and email addresses. If an email is detected, +an invitation is sent directly to the email. If a handle is detected, the script queries the GitHub +API to resolve the user's ID and sends the invitation using that ID. + +To authenticate with the GitHub API, a personal access token (PAT) must be provided with +"admin:org" scope. Invitations are sent via the endpoint: +https://api.github.com/orgs/{org}/invitations. + +Each invitation attempt is logged to the console, indicating whether it succeeded or failed. The +script does not skip or filter out existing organization members; it attempts to invite everyone +listed in the file. + +PowerShell 7 or later is required for this script due to its use of newer language features. + .PARAMETER LicensesFile The path of the consumed licenses CSV.