question

Jhon-5981 avatar image
0 Votes"
Jhon-5981 asked 76701045 published

Delete Azure ad b2c bulk users using powershell

Hello Team,

I'm trying to delete the Azure ad b2c users using bulk option from azure adb2c portal and ended up with the error.

currently our users with their signinnames shows as user principle name in azure ad b2c portal. but when i try to delete using bulk operation through csv file. It is not able to find the user with specific UPN and we realized that in the backedend the UPN is different.

error: 23715-image.png
can anyone help us?

we want to delete plenty of users on azure ad b2c

regards,
John


azure-ad-b2c
image.png (6.0 KiB)
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

How we can add users in bulk (without an invite)
55131-image.png


0 Votes 0 ·
image.png (7.8 KiB)

How we can add users in bulk (without an invite)

0 Votes 0 ·
amanpreetsingh-msft avatar image
0 Votes"
amanpreetsingh-msft answered

Hi @Jhon-5981,

To delete users in bulk, you can follow below steps:

  • Navigate to Azure AD B2C > Users > All Users > Bulk Operations > Download Users. This will download a list of all users in the B2C tenant with their original UPN, Display name, Mail, AlternateEmailAddress and so on in a CSV file.

  • Navigate to Azure AD B2C > Users > All Users > Bulk Operations > Bulk Delete and download CSV file.

  • From the file downloaded in step 1, copy the UPNs of the users that you want to delete and paste in the file downloaded in step 2, as shown below:
    23710-image.png

  • Navigate to Azure AD B2C > Users > All Users > Bulk Operations > Bulk Delete and upload the updated file.

  • Type 'Yes' to continue and click on submit.

Note: This will soft delete all the users listed in the uploaded file. Which means the users will be moved to Deleted users and then gets hard/permanently deleted automatically after 30 days. If you want to permanently delete the users before 30 days, you'll have to manually delete the users from the Deleted users blade.


Please "Accept the answer" if the information helped you. This will help us and others in the community as well.


image.png (6.4 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Jhon-5981 avatar image
0 Votes"
Jhon-5981 answered

Hi Aman,

thanks for your answer. But i'm looking for more to use power-shell. The answer which you have is already known.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

amanpreetsingh-msft avatar image
0 Votes"
amanpreetsingh-msft answered amanpreetsingh-msft commented

Hi @Jhon-5981 Please find below the script for this purpose:

 Connect-MsolService #sign-in using Global Admin of your B2C tenant. User should be Member of the tenant and not signed-up or guest user.
 $users = import-csv C:\temp\users.csv
 foreach ($usr in $users)
 {
 Remove-MsolUser -UserPrincipalName $usr.upn -Force
 }

Below is how the user.csv file looks:
26037-image.png


Please "Accept the answer" if the information helped you. This will help us and others in the community as well.


image.png (7.6 KiB)
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @Jhon-5981 Do you have any further questions?

0 Votes 0 ·

Hi @Jhon-5981 Have you had a chance to try the script?

0 Votes 0 ·