Skip to content

Update invite_members_to_org.ps1 #782

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
16 changes: 15 additions & 1 deletion api/powershell/invite_members_to_org.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.

Expand Down