Skip to content

Instantly share code, notes, and snippets.

@dev-kperera
Last active February 20, 2020 18:27
Show Gist options
  • Save dev-kperera/b0e48d2138b849123855879b48c2c1f8 to your computer and use it in GitHub Desktop.
Save dev-kperera/b0e48d2138b849123855879b48c2c1f8 to your computer and use it in GitHub Desktop.
CSV headers: InvitedUserEmailAddress, DispName, RedirectURL
# connect
$cred = Get-Credential
Connect-AzureAD -Credential $cred
# setting variables
$invitations = import-csv ..\invitations.csv
$messageInfo = New-Object Microsoft.Open.MSGraph.Model.InvitedUserMessageInfo
$messageInfo.customizedMessageBody = "Hey there! Check this out. I created an invitation through PowerShell"
# loop
foreach ($email in $invitations) {
New-AzureADMSInvitation -InvitedUserEmailAddress $email.InvitedUserEmailAddress -InvitedUserDisplayName $email.DispName -InviteRedirectUrl $email.RedirectURL -InvitedUserMessageInfo $messageInfo -SendInvitationMessage $true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment