AWS/Azure/OpenShift

Perform Bulk User Operations in Azure AD

Bulk-operations-in-Azure-AD

In this post, I show you how to perform bulk user operations in Azure AD. Azure AD or Azure Active Directory is a part of Microsoft Entra. It is an enterprise identity service that provides single sign-on, multifactor authentication, and conditional access to guard against 99.9 per cent of cybersecurity attacks. To use Azure AD, you must have an Azure AD Tenant set up for your organization. Azure AD also enables you to sync your on-premises directory to the Cloud by using the Azure AD Connect tool. To learn more about using Azure AD for your on-premises, review the various methods of integrating Azure Active Directory with on-Premise Active Directory

Azure Active Directory (Azure AD) allows enterprises to create new users in bulk, delete current users in mass, and restore deleted users in bulk. To download the selected users from the Azure AD interface, you must first fill out a comma-separated values (CSV) template. You can also learn how to manage Microsoft 365 User Accounts account such as account creation, assigning licenses, and viewing unlicensed accounts with PowerShell.

Creating Bulk Users in Azure AD

To carry out bulk user operations in the Azure AD portal using the Microsoft Entra admin center, you must sign-in as a Global Administrator or User Administrator.

To perform tasks such as bulk user creation, deletion and restoration, an administrator must download the UserCreateTemplate, UserDelete, and UserRestoreTemplate CSV file from the Azure AD Portal. The CSV template for bulk user creations differs significantly from the template for bulk user deletions, which differs slightly from the template for bulk user restoration of deleted users. For the appropriate bulk procedure, organizations should download and complete the CSV template.

To create bulk users using the UserCreateTemplate CSV file, follow the steps below:

Step 1: Log into the Azure AD Portal using an account with either Global administrator or User administrator privileges.
Step 2: From the Azure AD admin center, select Users > Bulk create

Bulk-Create-users
Downloading the UserCreateTemplate CSV File

On the  Bulk Create user page, select Download to download a valid comma-separated values (CSV) file of user properties, and then add the users you want to create as shown below. Note, you’re not expected to alter the column headings of the CSV template.

Filled-bulk-create-excel-sheet
Filled UserCreateTemplate CSV File

Step 3: On the Bulk Create user page, click on Upload to upload your CSV file, browse to the file and click on Submit to start validating the CSV file.

bulk-create-file-uploaded-2
UserCreateTemplate CSV File Uploaded

After the system validates the file contents, a File uploaded successfully message appears. If there are errors, you must fix them before you can submit the job.

Checking the status of the bulk operations

You can check the status of the bulk operation on the Bulk operation results page.

Success-status-bulk-user-creation
Status of Bulk User Creation

From the status screen above, only one operation reportedly failed because the user matches an existing user name in my Azure AD. If you navigate to the user list in your Azure AD, you would see all the newly created users.

list-of-bulk-users-created
Newly Created Users

Please see How to Upload Batch Files to Azure Storage Account Using Azure CLI, How to Batch rename multiple files on Windows, How to use the built-in Azure Active Directory Connect tool, how to Visualize MBAM Recovery Audit Report with Python, and How to Rename or Move a File or Directory in Linux – Bash Terminal Command.

Verify users were created using PowerShell

To confirm that users were created using PowerShell, you must first call the Connect-MgGraph -Scopes 'User.Read.All' Cmdlet command. After calling the command, run the below command to verify that those users were created:

Get-MgUser -Filter "UserType eq 'Member'"
6-newly-created-users-verified
Newly created users verified

Deleting Users in Bulk

The same way we created users by downloading the CSV file from the Azure AD Portal is the same we will also delete users. The delete user operation uses a CSV file to identify the users you want to delete.

The CSV template used for bulk deletion looks a little bit different from the template used for bulk creation. The template only requires one column instead two columns as shown in the below screenshot.

bulk-delete-template-sample
Sample User Delete Template
The rows in the downloaded CSV template to bulk deleted existing users are as follows:

1. Version number. The upload CSV file must contain the version number in the first row.
2. Column headings. User name [userPrincipalName] Required. Older versions of the template may vary.
3. Examples row. The template includes an example of an acceptable value. Example: chris@contoso.com. 
Note: You must remove the example row and replace it with your own entries.

Take the following steps to accomplish the bulk user delete operations:

Step 1: Navigate to All Users > Bulk deletes> Download the UserDelete CSV file.

download-bulk-delete-template
Bulk User Delete Operation

Step 2: Complete the entries with the names of the users you want to delete.

Users-to-bulk-delete-loaded
Users to be deleted in Bulk

Step 3: Upload the complete User delete CSV file back to the Azure AD portal for validation and further action.

At this point, you will be prompted to type “Yes” to confirm the deletion operation. Go ahead and type Yes and then Submit. You can assess the “Click here to view the status of each operation” to view the status.

bulk-delete-success-status
User Delete Status

From the screenshot above only one user failed the deletion operation. Download the task to view the failure reason as shown below:

failed-reason-for-bulk-delete-users
User delete failure reason

Now that we have learned how to bulk create and delete users, let us see how we can also restore the deleted users in bulk.

Restoring Users in Bulk

Just it is required to download the UserCreateTemplate and UserDelete CSV file, it is also required that we download the UserRestoreTemplate.

To restore bulk users, follow the following steps:

Step 1: Download the UserRestoreTemplate CSV file by navigating to the Users > Deleted users > Bulk restore > Download.

bulk-restore-template
Downloading the Bulk User Restore Template

Step 2: Complete the UserRestoreTemplate CSV file with all the entries you want to restore.

deleted-users-to-restore
Deleted users to be restored
Note, only Object ID are required to restore deleted users. You can call the Object ID by running the Get-AzureADUser cmdlet command

Step 3: Uploaded the UserRestoreTemplate to the Azure AD portal for further action.

upload-the-deleted-users
UserRestoreTemplate CSV file uploaded

Next, you will see the successful prompt that the file was successfully uploaded. Click on Submit to submit the task.

submit-deleted-template
Submitting UserRestoretemplate

You will receive a notification for the successful restoration of the deleted users.

deleted-users-restored-success
Deleted users restored

You can click download the file to see the result.

Restored-success-excel-file
Deleted Users restored

In conclusion, Azure AD enables organizations of all sizes to empower their employees to collaborate and access external resources, such as Microsoft 365, the Azure portal, and thousands of other SaaS applications. It also helps them access internal resources like apps on your corporate intranet, and any cloud apps developed for your own organization. With Azure Active Directory (Azure AD), you can create, verify created users using PowerShell, and delete, and restore users in bulk. This action helps to improve efficiency and save time.

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x