Invite Guest users with custom invitation message in AAD using a powershell

Kerwin Rean Kallego 61 Reputation points
2023-05-29T06:31:50.6966667+00:00

I need some ps code preference for my project.

PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,943 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
24,591 questions
0 comments No comments
{count} votes

Accepted answer
  1. Harpreet Singh Matharoo 8,376 Reputation points Microsoft Employee Moderator
    2023-05-29T10:04:04.0866667+00:00

    Hello @Kerwin Rean Kallego ,

    Thank you for reaching out this. We can send guest invites using Azure AD PowerShell module using following script:

    # Install the AzureAD module if not already installed 
    Install-Module -Name AzureAD  
    
    # Import the AzureAD module 
    Import-Module AzureAD  
    
    # Connect to Azure AD 
    Connect-AzureAD  
    
    # Set the required parameters 
    $displayName = "SD Test" 
    $emailAddress = "******@domain.com" 
    $customInvitationMethod = "CustomMethod" 
    $customizedMessageBody = "This is a Test Custom Message Body"  
    
    # Create the invitation 
    $invitation = New-AzureADMSInvitation -InvitedUserDisplayName $displayName -SendInvitationMessage $True -InvitedUserEmailAddress $emailAddress -InviteRedirectUrl "https://myapplications.microsoft.com" -InvitedUserMessageInfo @{ "MessageLanguage" = "en-US"; "CustomizedMessageBody" = $customizedMessageBody } -InvitedUserType Guest   
    
    # Display the invitation details 
    $invitation
    

    PS Output:
    User's image

    Invitation sample:
    User's image

    Please "Accept the answer" if the information helped you. This will help us and others in the community as well.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.