Adding guest users manually can be tedious if you have many invites. Using PowerShell automates this process efficiently.
Note: The AzureAD module is older and deprecated. Microsoft Graph is the modern alternative.
Install-Module Microsoft.Graph -Scope CurrentUser
Connect-MgGraph -Scopes "User.ReadWrite.All"
Login with a Global Admin or User Administrator account.
⚠️ The scope
User.ReadWrite.Allis a permission, not your email.
Create a CSV file named Guests.csv with the following format:
FirstName,LastName,Email
John,Doe,john.doe@example.com
Jane,Smith,jane.smith@example.com
Save it somewhere easy to access, e.g., C:\\Path\\To\\Guests.csv.
# Import CSV
$guests = Import-Csv "C:\\Path\\To\\Guests.csv"
foreach ($guest in $guests) {
$displayName = "$($guest.FirstName) $($guest.LastName)"
$email = $guest.Email
# Create guest user invitation
New-MgInvitation -InvitedUserEmailAddress $email `
-InviteRedirectUrl "<https://portal.office.com>" `
-InvitedUserDisplayName $displayName `
-SendInvitationMessage:$true
}