Can I invite a guest user in azure active directory using powershell

Hi All,

I am trying to add an external user (user from another domain) into my Azure AD.
I am able to perform the same from Azure ARM portal (through ‘Add a guest user’). However, I am not able to perform the same using powershell.
Any suggestion as to how this can be performed?

Let me know if any further explanation is required.

Regards,
Deep

I’m not sure they’ve presently exposed that functionality via PowerShell. In fact, after some cursory research, I’m not sure the underlying Graph API supports this, which means the portal might be the only supported mechanism. You’d have to open a support ticker with Azure to confirm.

Hi Don,

Thank you for your reply.
By using AzureAD module this worked, however unable to assign a co-administrator role to the added user.

Below is the script which I used for sending out an invitation.

$email = Read-Host -Prompt ‘Please provide the email Id of the user’
$userName = Read-Host -Prompt ‘Enter the User Name’

Write-Host "Sending invitation to $userName " -f Green
$messageInfo = New-Object Microsoft.Open.MSGraph.Model.InvitedUserMessageInfo
$messageInfo.customizedMessageBody = “Hey $userName, `n Click on the Get Started link to start exploring”
New-AzureADMSInvitation -InvitedUserEmailAddress $email -InvitedUserDisplayName $userName -InviteRedirectUrl https://myapps.microsoft.com/ -InvitedUserMessageInfo $messageInfo -SendInvitationMessage $true
Write-Host “Invitation sent successfully” -f Green