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: includes/active-directory-identity-governance-applications-retrieve-users.md
+40-5Lines changed: 40 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -45,11 +45,11 @@ The first time your organization uses these cmdlets for this scenario, you need
45
45
46
46
1. Choose the column of the *users.csv* file that will match with an attribute of a user in Azure AD.
47
47
48
-
For example, you might have users in the database where the value in the column named `EMail` is the same value as in the Azure AD attribute `mail`:
48
+
For example, you might have users in the database where the value in the column named `EMail` is the same value as in the Azure AD attribute `userPrincipalName`:
49
49
50
50
```powershell
51
51
$db_match_column_name = "EMail"
52
-
$azuread_match_attr_name = "mail"
52
+
$azuread_match_attr_name = "userPrincipalName"
53
53
```
54
54
55
55
1. Retrieve the IDs of those users in Azure AD.
@@ -123,14 +123,49 @@ The first time your organization uses these cmdlets for this scenario, you need
123
123
124
124
1. When the script finishes, it will indicate an error if any records from the data source weren't located in Azure AD. If not all the records for users from the application's data store could be located as users in Azure AD, you'll need to investigate which records didn't match and why.
125
125
126
-
For example, someone's email address might have been changed in Azure AD without their corresponding `mail` property being updated in the application's data source. Or, the user might have already left the organization but is still in the application's data source. Or there might be a vendor or super-admin account in the application's data source that does not correspond to any specific person in Azure AD.
126
+
For example, someone's email address and userPrincipalName might have been changed in Azure AD without their corresponding `mail` property being updated in the application's data source. Or, the user might have already left the organization but is still in the application's data source. Or there might be a vendor or super-admin account in the application's data source that does not correspond to any specific person in Azure AD.
127
127
128
128
1. If there were users who couldn't be located in Azure AD, or weren't active and able to sign in, but you want to have their access reviewed or their attributes updated in the database, you need to update or create Azure AD users for them. You can create users in bulk by using either:
129
129
130
130
- A CSV file, as described in [Bulk create users in the Azure AD portal](../articles/active-directory/enterprise-users/users-bulk-add.md)
131
131
- The [New-MgUser](/powershell/module/microsoft.graph.users/new-mguser?view=graph-powershell-1.0#examples&preserve-view=true) cmdlet
132
132
133
-
Ensure that these new users are populated with the attributes required for Azure AD to later match them to the existing users in the application.
133
+
Ensure that these new users are populated with the attributes required for Azure AD to later match them to the existing users in the application, and the attributes required by Azure AD, including `userPrincipalName`, `mailNickname` and `displayName`. The `userPrincipalName` must be unique among all the users in the directory.
134
+
135
+
For example, you might have users in the database where the value in the column named `EMail` is the value you want to use as the Azure AD user principal Name, the value in the column `Alias` contains the Azure AD mail nickname, and the value in the column `Full name` contains the user's display name:
136
+
137
+
```powershell
138
+
$db_display_name_column_name = "Full name"
139
+
$db_user_principal_name_column_name = "Email"
140
+
$db_mail_nickname_column_name = "Alias"
141
+
```
142
+
143
+
Then you can use this script to create Azure AD users for those in the database or directory that didn't match with users in Azure AD. Note that you may need to modify this script to add additional Azure AD attributes needed in your organization, or if the `$azuread_match_attr_name` is neither `mailNickname` nor `userPrincipalName`, in order to supply that Azure AD attribute.
144
+
145
+
```powershell
146
+
$dbu_missing_columns_list = @()
147
+
$dbu_creation_failed_list = @()
148
+
foreach ($dbu in $dbu_not_matched_list) {
149
+
if (($null -ne $dbu.$db_display_name_column_name -and $dbu.$db_display_name_column_name.Length -gt 0) -and
0 commit comments