Using New-MgInvitation for Bulk Guest User Creation in Azure AD

AZ-104 By islever Editorial Last updated

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

Note: This question is part of a series of questions that present the same scenario. Each question in the series contains a unique solution that might meet the stated goals. Some question sets might have more than one correct solution, while others might not have a correct solution.
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?
  1. Yes Correct Answer
  2. No

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?

It sends an invitation. The guest user account is created in the directory when the recipient clicks the link and accepts the invitation.

Is there a better way than scripting 500 invitations?

Yes, the Azure Portal offers a 'Bulk invite users' operation which is faster for large numbers, but the scripted approach is still technically correct and valid.

Community Votes

A
72%
B
28%

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

  1. iamchoy 👍 31 Answered A
    The 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
  2. Shark006 👍 16
    The 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
  3. tech07 👍 8 Answered A
    New-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
  4. Batiste2023 👍 8
    As you run the command from a script, you can hardcode a redirection URL into it. A is correct, I would say!
  5. Shark006 👍 6
    The 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
  1. BillDilena 👍 5 Answered A
    From 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.
  2. Killic 👍 5
    Correct. 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
  3. ajdann 👍 5
    The new-mginvitation command requires -InviteRedirectUrl which is not provided in the given CSV. So I would conlcude that the answer is B
  4. AchillesA 👍 5
    You only need the "InviteRedirectUrl" when inviting users through the Azure portal. If you're using powershell then you don't need it.
  5. jackill 👍 4 Answered A
    https://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.
  6. ggogel 👍 4
    There 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.
  7. Javad 👍 4
    The 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.
  8. Korny11 👍 4
    I 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
  9. 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
  10. ggogel 👍 4
    After 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.
  11. JeremyChainsaw 👍 4
    A, YES. this is calling out the Azure Graph API CMDlet New-MgInvitation, which is the equivalent of the Azure AD Cmdlet New-AzureADMSInvitation.
  12. clg003 👍 3 Answered A
    Yes 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
  13. 60ties 👍 3 Answered A
    As 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
  14. TheDataGuy 👍 3
    I 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
  15. 3GS 👍 3 Answered A
    Example: PS C:\> New-MgInvitation -InvitedUserDisplayName "John Doe" -InvitedUserEmailAddress [email protected] -InviteRedirectUrl "https://myapplications.microsoft.com" -SendInvitationMessage:$true
  16. InvalidNickname 👍 3
    This 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
  17. extopacct 👍 3
    Answer 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.
  18. Hamza576 👍 3
    It 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
  19. RandomNickname 👍 3 Answered A
    https://learn.microsoft.com/en-us/azure/active-directory/external-identities/b2b-quickstart-invite-powershell Answer looks correct
  20. ziggy1117 👍 3 Answered B
    needs redirection URL
  21. DimsumDestroyer 👍 2
    Answer 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:"
  22. amsioso 👍 2
    By 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
  23. VivekBishnoi1982 👍 2 Answered B
    I 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 }
  24. rhamilton 👍 2 Answered A
    A 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
  25. SDiwan 👍 2
    the 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.

Log in to comment, report an error, or add a note about this question.

Practice All AZ-104 Questions

Access 100 questions with complete answers and detailed explanations.

View Full AZ-104 Practice Test →

← Back to AZ-104 Study Guide