You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/active-directory/b2b/bulk-invite-powershell.md
+26-20Lines changed: 26 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,33 +33,36 @@ If you don’t have an Azure subscription, create a [free account](https://azure
33
33
## Prerequisites
34
34
35
35
### Install the latest AzureADPreview module
36
+
36
37
Make sure that you install the latest version of the Azure AD PowerShell for Graph module (AzureADPreview).
37
38
38
39
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
41
42
Get-Module -ListAvailable AzureAD*
42
43
```
43
44
44
45
Based on the output, do one of the following:
45
46
46
47
- If no results are returned, run the following command to install the AzureADPreview module:
47
48
48
-
```powershell
49
+
```powershell
49
50
Install-Module AzureADPreview
50
51
```
52
+
51
53
- If only the AzureAD module shows up in the results, run the following commands to install the AzureADPreview module:
52
54
53
-
```powershell
54
-
Uninstall-Module AzureAD
55
-
Install-Module AzureADPreview
55
+
```powershell
56
+
Uninstall-Module AzureAD
57
+
Install-Module AzureADPreview
56
58
```
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:
58
59
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
+
```
63
66
64
67
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.
65
68
@@ -69,11 +72,10 @@ You need two or more test email accounts that you can send the invitations to. T
69
72
70
73
## Prepare the CSV file
71
74
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.
73
76
74
77
For example, create a worksheet in the following format:
75
78
76
-
77
79

78
80
79
81
Save the file as **C:\BulkInvite\Invitations.csv**.
@@ -87,22 +89,23 @@ Run the following command to connect to the tenant domain:
@@ -111,16 +114,19 @@ foreach ($email in $invitations)
111
114
-SendInvitationMessage $true
112
115
}
113
116
```
117
+
114
118
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:
115
119
116
120

117
121
118
122
## Verify users exist in the directory
119
123
120
124
To verify that the invited users were added to Azure AD, run the following command:
125
+
121
126
```powershell
122
127
Get-AzureADUser -Filter "UserType eq 'Guest'"
123
128
```
129
+
124
130
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.
125
131
126
132
## Clean up resources
@@ -130,12 +136,12 @@ When no longer needed, you can delete the test user accounts in the directory. R
130
136
```powershell
131
137
Remove-AzureADUser -ObjectId "<UPN>"
132
138
```
133
-
For example: `Remove-AzureADUser -ObjectId "lstokes_fabrikam.com#EXT#@contoso.onmicrosoft.com"`
134
139
140
+
For example: `Remove-AzureADUser -ObjectId "lstokes_fabrikam.com#EXT#@contoso.onmicrosoft.com"`
135
141
136
142
## Next steps
143
+
137
144
In this tutorial, you sent bulk invitations to guest users outside of your organization. Next, learn how the invitation redemption process works.
138
145
139
146
> [!div class="nextstepaction"]
140
147
> [Learn about the Azure AD B2B collaboration invitation redemption process](redemption-experience.md)
0 commit comments