Using New-MgInvitation for Bulk Guest User Creation in Azure AD
Short answer
A Yes, creating a PowerShell script that runs the New-MgInvitation cmdlet for each external user meets the goal of creating guest user accounts in contoso.com.
Question
After you answer a question in this section, you will NOT be able to return to it. As a result, these questions will not appear in the review screen.
You have an Azure Active Directory (Azure AD) tenant named contoso.com.
You have a CSV file that contains the names and email addresses of 500 external users.
You need to create a guest user account in contoso.com for each of the 500 external users.
Solution: You create a PowerShell script that runs the New-MgInvitation cmdlet for each external user.
Does this meet the goal?
Key Takeaways
The main trap is assuming that because a 'Bulk Invite' portal option exists, programmatic individual invitations via a looped script are invalid; however, both methods are supported for creating guest users.
This page explains why using the New-MgInvitation cmdlet in a PowerShell script correctly creates guest user accounts in Azure AD, addressing a common AZ-104 exam scenario regarding bulk identity management.
Common mistake: Selecting 'No' because one believes only the specific 'Bulk invite users' portal feature counts as 'bulk', ignoring that a scripted loop of single-invitation cmdlets achieves the same outcome programmatically.
Expert Analysis
The question asks whether using a PowerShell script with the New-MgInvitation cmdlet to create guest user accounts for 500 external users meets the goal. The key here is understanding the function of New-MgInvitation. This cmdlet, part of the Microsoft Graph PowerShell module, sends an invitation to an external user's email address. When the recipient accepts the invitation, they are created as a guest user in the Azure AD tenant.
While the comment suggesting 'B' argues that the official quickstart examples show single-user invocations, this reasoning is flawed because PowerShell scripts are inherently iterative. A script can easily read a CSV file (using Import-Csv) and loop through each row, executing New-MgInvitation for every entry. Therefore, the method described—running a script that invokes the cmdlet for each user—is a valid and supported approach for bulk inviting guests, even if there is also a dedicated 'Bulk invite users' operation in the portal. The question does not require the most efficient tool, only whether the proposed solution meets the goal. Since sending individual invitations via a script successfully creates guest accounts upon redemption, it meets the requirement.
The common mistake is assuming that because a 'Bulk Invite' UI feature exists, any other method is incorrect or insufficient. However, Microsoft supports multiple methods for identity management, including programmatic access via Graph API/PowerShell. The New-MgInvitation cmdlet is specifically designed for this purpose. Getting this wrong might lead to overlooking valid automation strategies in real-world scenarios where GUI-based bulk tools might be restricted or unavailable.
Exam Strategy
When evaluating solutions for identity management tasks, always consider if the proposed technical action achieves the end state, regardless of whether it is the most 'native' UI-based method. For guest users, remember that New-MgInvitation creates the guest record upon acceptance, making it a valid building block for automation scripts targeting bulk operations.
Frequently Asked Questions
Does New-MgInvitation create the guest user immediately?
Is there a better way than scripting 500 invitations?
Community Votes
72% of anonymous learners picked answer A. Votes are pick records left by other test-takers — they are not the verified answer.
Discussion 54 contributions
Compiled from public community threads and reader submissions, lightly edited for clarity. Handles and vote tallies are shown as recorded, and comments reflect the views of individual contributors.
From public community threads 30 of 54
-
iamchoy 👍 31 Answered AThe New-MgInvitation cmdlet is part of the Microsoft Graph PowerShell module. It's used to create an invitation to an external user. When the invited user redeems their invitation, a guest user is created in the directory. If you use a PowerShell script that loops through each external user in the CSV file and runs the New-MgInvitation cmdlet for each of them, it will send out invitation emails to each of those external users. Once an external user accepts the invitation, they'll be added to the Azure AD tenant as a guest user. So, using the New-MgInvitation cmdlet in a PowerShell script for each external user does meet the goal of creating a guest user account in contoso.com for each of the 500 external users. The answer is: A. Yes
-
Shark006 👍 16The cmdlet New-MgInvitation requires the Redirection URL. "The URL the user should be redirected to once the invitation is redeemed. Required." Reference: https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.identity.signins/new-mginvitation?view=graph-powershell-1.0 So the answer is: B. No
-
tech07 👍 8 Answered ANew-AzureADMSInvitation or New-MgInvitation can be used to invite users, Not New-MgUser https://learn.microsoft.com/en-us/powershell/microsoftgraph/azuread-msoline-cmdlet-map?view=graph-powershell-1.0#users
-
Batiste2023 👍 8As you run the command from a script, you can hardcode a redirection URL into it. A is correct, I would say!
-
Shark006 👍 6The answer is B but the justification is wrong after reconsideration. "The URL the user should be redirected to once the invitation is redeemed. Required." Reference: https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.identity.signins/new-mginvitation?view=graph-powershell-1.0
Show 25 more comments
-
BillDilena 👍 5 Answered AFrom MS documentation: https://learn.microsoft.com/en-us/azure/active-directory/external-identities/bulk-invite-powershell Prepare the CSV file In Microsoft Excel, create a CSV file with the list of invitee user names and email addresses. Make sure to include the Name and InvitedUserEmailAddress column headings. Enough the CSV with names and emails.
-
Killic 👍 5Correct. I believe "New-AzureADMSInvitation" is used to bulk invite guests from CSV file. Source: https://learn.microsoft.com/en-us/azure/active-directory/external-identities/bulk-invite-powershell
-
ajdann 👍 5The new-mginvitation command requires -InviteRedirectUrl which is not provided in the given CSV. So I would conlcude that the answer is B
-
AchillesA 👍 5You only need the "InviteRedirectUrl" when inviting users through the Azure portal. If you're using powershell then you don't need it.
-
jackill 👍 4 Answered Ahttps://learn.microsoft.com/en-us/azure/active-directory/external-identities/bulk-invite-powershell#send-bulk-invitations describes exactly the same task required by this question, and the proposed script uses New-AzureADMSInvitation cmdlet. But page https://learn.microsoft.com/en-us/powershell/microsoftgraph/overview?view=graph-powershell-1.0 says: "Microsoft Graph PowerShell is the replacement for the Azure AD PowerShell and MSOnline modules and is recommended for interacting with Azure AD.". By searching the Microsoft Graph PowerShell command equivalent of New-AzureADMSInvitation in this page https://learn.microsoft.com/en-us/powershell/microsoftgraph/azuread-msoline-cmdlet-map?view=graph-powershell-1.0#users I find the command New-MgInvitation. So my reply to this question is "A" : yes.
-
ggogel 👍 4There simply is no clear answer to this question! If you use the CSV in PowerShell, you would need another Cmdlet Import-Csv to read the CSV file. Then, you could iterate over the email addresses and specify the same redirection URL for every guest. On the other hand, there is the same question about using Azure Portal Bulk Import. I could also argue that I can simply open the file in Excel and set a redirection URL for every user. So it really comes down to how you interpret the question. Suppose you can just use the existing CSV and the given Cmdlet or Azure Bulk Import, then the answer is always FALSE. If you can add one extra step or Cmdlet, then it is always TRUE.
-
Javad 👍 4The New-AzureADMSInvitation cmdlet can be used to send an invite to a single user. In a large environment, we may need to send an invite for bulk external users. Create the CSV file “GuestUsers. csv” (Download sample CSV) with the column headers UserName and EmailAddress. So the answer should be No I believe.
-
Korny11 👍 4I would go for B. The cmdlet is correct but the required parameter "-InviteRedirectUrl" is missing in the CSV as mentioned here https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.identity.signins/new-mginvitation?view=graph-powershell-1.0&preserve-view=true#-inviteredeemurl
-
urbanmonk 👍 4"You create a PowerShell script that runs the New-MgInvitation cmdlet for each external user" Note the use of the phrase "for each external user". So the solution meets the goal. For me, it is A
-
ggogel 👍 4After reading the question again, it says: "you create a PowerShell script". In my opinion, this implies that we can use other Cmdlets. So I would lean towards "YES" here.
-
JeremyChainsaw 👍 4A, YES. this is calling out the Azure Graph API CMDlet New-MgInvitation, which is the equivalent of the Azure AD Cmdlet New-AzureADMSInvitation.
-
clg003 👍 3 Answered AYes with New-MgInvitation the -InviteRedirectUrl flag is not required. You can also put one in with the command line. "-InviteRedirectUrl Required: False" https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.identity.signins/new-mginvitation?view=graph-powershell-1.0
-
60ties 👍 3 Answered AAs per this link: “https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.identity.signins/new-mginvitation?view=graph-powershell-1.0” The “InviteRedirectUrl” requirement is a Boolean. So can be included (as True) or ignored (as False). So A is the correct answer
-
TheDataGuy 👍 3I am going to say answer is A. Yes: PS C:\> New-MgInvitation -InvitedUserDisplayName "John Doe" -InvitedUserEmailAddress [email protected] -InviteRedirectUrl "https://myapplications.microsoft.com" -SendInvitationMessage:$true
-
3GS 👍 3 Answered AExample: PS C:\> New-MgInvitation -InvitedUserDisplayName "John Doe" -InvitedUserEmailAddress [email protected] -InviteRedirectUrl "https://myapplications.microsoft.com" -SendInvitationMessage:$true
-
InvalidNickname 👍 3This question has appeared previously and then given reason for the answer to be "No" was that in the CSV file "InviteRedirectUrl" was missing. I believe this would be "NO" as well. Answer: B
-
extopacct 👍 3Answer is B: You are asked to create the accounts. new-mginvitation used by itself is used for the invitation only. It does not create the accounts.
-
Hamza576 👍 3It mentions here that we create a script powershell that run that command so it can be trough a foreach loop as I understood. So for me it is A
-
RandomNickname 👍 3 Answered Ahttps://learn.microsoft.com/en-us/azure/active-directory/external-identities/b2b-quickstart-invite-powershell Answer looks correct
-
ziggy1117 👍 3 Answered Bneeds redirection URL
-
DimsumDestroyer 👍 2Answer is A: When you use this cmdlet, it also adds/creates the external users to your AAD. But for them to be able to access your organization's resources, they need an invitation to accept. This is no different from manually inviting a guest user on the UI. The difference is if you need to bulk add guest users, you can use powershell and this cmdlet to do it with a CSV, hence this solution meets the goal. FROM: https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.identity.signins/new-mginvitation?view=graph-powershell-1.0 "Use this API to create a new invitation. Invitation adds an external user to the organization. When creating a new invitation, you have several options available:"
-
amsioso 👍 2By portal you need to include the Redirection URL in the csv. https://learn.microsoft.com/en-us/entra/external-id/tutorial-bulk-invite Making it with Powershell yo dont need to include in the csv the Redirection URL. If we can change New-AzureADMSInvitation for New-MgInvitation in the PowerShell script then the answer is A. https://learn.microsoft.com/en-us/entra/external-id/bulk-invite-powershell?source=recommendations#send-bulk-invitations
-
VivekBishnoi1982 👍 2 Answered BI believe InviteRedirectUrl is still needed else it won't create foreach ($email in $invitations) {New-AzureADMSInvitation -InvitedUserEmailAddress $email.InvitedUserEmailAddress -InvitedUserDisplayName $email.Name -InviteRedirectUrl https://myapps.microsoft.com -InvitedUserMessageInfo $messageInfo -SendInvitationMessage $true }
-
rhamilton 👍 2 Answered AA is correct: Use this API to create a new invitation. Invitation adds an external user to the organization. https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.identity.signins/new-mginvitation?view=graph-powershell-1.0
-
SDiwan 👍 2the correct answer is "A". We can assume that invitation url is present in the powershell script. also, it mentions the command is used for "each" user, so assuming there is a loop and this command runs for each user inside the loop.
Reader comments & corrections
No reader corrections yet — spotted an error or have a note? Share it below.
Related Analysis
Practice All AZ-104 Questions
Access 100 questions with complete answers and detailed explanations.
View Full AZ-104 Practice Test →