Skip to content

Commit 5c97f8d

Browse files
committed
fixes
1 parent cb71481 commit 5c97f8d

File tree

1 file changed

+26
-20
lines changed

1 file changed

+26
-20
lines changed

articles/active-directory/b2b/bulk-invite-powershell.md

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,33 +33,36 @@ If you don’t have an Azure subscription, create a [free account](https://azure
3333
## Prerequisites
3434

3535
### Install the latest AzureADPreview module
36+
3637
Make sure that you install the latest version of the Azure AD PowerShell for Graph module (AzureADPreview).
3738

3839
First, check which modules you have installed. Open Windows PowerShell as an elevated user (Run as administrator), and run the following command:
39-
40-
```powershell
40+
41+
```powershell
4142
Get-Module -ListAvailable AzureAD*
4243
```
4344

4445
Based on the output, do one of the following:
4546

4647
- If no results are returned, run the following command to install the AzureADPreview module:
4748

48-
```powershell
49+
```powershell
4950
Install-Module AzureADPreview
5051
```
52+
5153
- If only the AzureAD module shows up in the results, run the following commands to install the AzureADPreview module:
5254

53-
```powershell
54-
Uninstall-Module AzureAD
55-
Install-Module AzureADPreview
55+
```powershell
56+
Uninstall-Module AzureAD
57+
Install-Module AzureADPreview
5658
```
57-
- If only the AzureADPreview module shows up in the results, but you receive a message that indicates there's a later version, run the following commands to update the module:
5859

59-
```powershell
60-
Uninstall-Module AzureADPreview
61-
Install-Module AzureADPreview
62-
```
60+
- If only the AzureADPreview module shows up in the results, but you receive a message that indicates there's a later version, run the following commands to update the module:
61+
62+
```powershell
63+
Uninstall-Module AzureADPreview
64+
Install-Module AzureADPreview
65+
```
6366

6467
You may receive a prompt that you're installing the module from an untrusted repository. This occurs if you haven't previously set the PSGallery repository as a trusted repository. Press **Y** to install the module.
6568

@@ -69,11 +72,10 @@ You need two or more test email accounts that you can send the invitations to. T
6972

7073
## Prepare the CSV file
7174

72-
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.
75+
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.
7376

7477
For example, create a worksheet in the following format:
7578

76-
7779
![PowerShell output showing pending user acceptance](media/tutorial-bulk-invite/AddUsersExcel.png)
7880

7981
Save the file as **C:\BulkInvite\Invitations.csv**.
@@ -87,22 +89,23 @@ Run the following command to connect to the tenant domain:
8789
```powershell
8890
Connect-AzureAD -TenantDomain "<Tenant_Domain_Name>"
8991
```
92+
9093
For example, `Connect-AzureAD -TenantDomain "contoso.onmicrosoft.com"`.
9194

9295
When prompted, enter your credentials.
9396

9497
## Send bulk invitations
9598

96-
To send the invitations, run the following PowerShell script (where **c:\bulkinvite\invitations.csv** is the path of the CSV file):
99+
To send the invitations, run the following PowerShell script (where **c:\bulkinvite\invitations.csv** is the path of the CSV file):
97100

98101
```powershell
99102
$invitations = import-csv c:\bulkinvite\invitations.csv
100-
103+
101104
$messageInfo = New-Object Microsoft.Open.MSGraph.Model.InvitedUserMessageInfo
102-
105+
103106
$messageInfo.customizedMessageBody = "Hello. You are invited to the Contoso organization."
104-
105-
foreach ($email in $invitations)
107+
108+
foreach ($email in $invitations)
106109
{New-AzureADMSInvitation `
107110
-InvitedUserEmailAddress $email.InvitedUserEmailAddress `
108111
-InvitedUserDisplayName $email.Name `
@@ -111,16 +114,19 @@ foreach ($email in $invitations)
111114
-SendInvitationMessage $true
112115
}
113116
```
117+
114118
The script sends an invitation to the email addresses in the Invitations.csv file. You should see output similar to the following for each user:
115119

116120
![PowerShell output showing pending user acceptance](media/tutorial-bulk-invite/B2BBulkImport.png)
117121

118122
## Verify users exist in the directory
119123

120124
To verify that the invited users were added to Azure AD, run the following command:
125+
121126
```powershell
122127
Get-AzureADUser -Filter "UserType eq 'Guest'"
123128
```
129+
124130
You should see the users that you invited listed, with a user principal name (UPN) in the format *emailaddress*#EXT#\@*domain*. For example, *lstokes_fabrikam.com#EXT#\@contoso.onmicrosoft.com*, where contoso.onmicrosoft.com is the organization from which you sent the invitations.
125131

126132
## Clean up resources
@@ -130,12 +136,12 @@ When no longer needed, you can delete the test user accounts in the directory. R
130136
```powershell
131137
Remove-AzureADUser -ObjectId "<UPN>"
132138
```
133-
For example: `Remove-AzureADUser -ObjectId "lstokes_fabrikam.com#EXT#@contoso.onmicrosoft.com"`
134139

140+
For example: `Remove-AzureADUser -ObjectId "lstokes_fabrikam.com#EXT#@contoso.onmicrosoft.com"`
135141

136142
## Next steps
143+
137144
In this tutorial, you sent bulk invitations to guest users outside of your organization. Next, learn how the invitation redemption process works.
138145

139146
> [!div class="nextstepaction"]
140147
> [Learn about the Azure AD B2B collaboration invitation redemption process](redemption-experience.md)
141-

0 commit comments

Comments
 (0)