Organizations invite external users to their Microsoft Entra ID directory to facilitate collaboration with individuals outside their organization. This allows for the controlled sharing of resources and the provision of temporary access while enabling external individuals to use their existing credentials.
Before using the New-MgInvitation cmdlet, ensure the following:
Install-Module Microsoft.Graph -Scope CurrentUser
User.Invite.All, User.ReadWrite.All, Directory.ReadWrite.All,
The New-MgInvitation cmdlet can be used in Microsoft Graph PowerShell to invite new external users into your directory. Here's the syntax:
New-MgInvitation
[-ResponseHeadersVariable <String>]
[-AdditionalProperties <Hashtable>]
[-Id <String>]
[-InviteRedeemUrl <String>]
[-InviteRedirectUrl <String>]
[-InvitedUser <IMicrosoftGraphUser>]
[-InvitedUserDisplayName <String>]
[-InvitedUserEmailAddress <String>]
[-InvitedUserMessageInfo <IMicrosoftGraphInvitedUserMessageInfo>]
[-InvitedUserSponsors <IMicrosoftGraphDirectoryObject[]>]
[-InvitedUserType <String>]
[-ResetRedemption]
[-SendInvitationMessage]
[-Status <String>]
[-Headers <IDictionary>]
[-ProgressAction <ActionPreference>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Example 1: Invite a user and send a default invitation email
New-MgInvitation -InvitedUserDisplayName "John Doe" -InvitedUserEmailAddress John@contoso.com -InviteRedirectUrl "https://myapplications.microsoft.com" -SendInvitationMessage:$true
Example 2: Invite a user and set the user type to member
New-MgInvitation -InvitedUserDisplayName "John Doe" -InvitedUserEmailAddress John@contoso.com -InviteRedirectUrl "https://myapplications.microsoft.com" -InvitedUserType Member
The following table contains some parameters that can be used along with the New-MgInvitation command to invite external users into your directory.
| Parameters | Description |
|---|---|
| -BodyParameter | This parameter sends an invitation to the external user. |
| -Headers | This parameter allows you to add optional headers to the request. |
| -Id | This parameter assigns a read-only unique identifier for an entity. |
| -InvitedUserType | This parameter determines the userType of the user being invited. |
| -InviteRedeemUrl | This parameter specifies the URL that the user can use to redeem their invitation. |
ManageEngine ADManager Plus is an identity governance and administration solution, with comprehensive Microsoft Entra ID management and reporting capabilities, that eliminates the hassle of complex PowerShell scripts. Its intuitive, user-friendly interface allows you to streamline even the most complex administrative tasks in minutes.
Here’s how it takes your AD management to the next level: