Deleting Users from Azure

You might have run into this issue where you need to delete a bunch of users from Azure. I’ve recently had to do this, and found that through the web application/gui you can only delete one user at a time. I had to delete over 5000 users and 6000 groups in order to migrate Azure Active Directories (story for another blog). It’s important to note that this could likely be related to Office 365 as well since we know that


You can do this through PowerShell, but it’s not straight forward.


There are some requirements you will need to manage this.

  • .Net 4.5.2
  • Microsoft Online Services Sign-In Assistant
  • Wndows Azure Active Directory Module for Windows PowerShell

First Step: Sign on to Azure via PowerShell

For this step you will need to use a Global Administrator account.

  • Start PowerShell
  • Store your Azure/Office 365 Global Administrator credentials

$credentials = get-credential


  • Connect to MSOL (Microsoft Online) Azure using your credentials

connect-msolservice -credential $credentials


To ensure you are connected to Azure, you can check your users using the cmdlet, get-msoluser the result should display your users.

Getting your users

Ok, we’ve now connected to Azure and showed you how to ensure you are connected to Azure. Now to gather a list of users and see how we can go about deleting them. For our purposes we want to delete the 3 dummy user accounts I’ve created.


The first cmdlet we will use will be a combination of getting all of our users and exporting them to a CSV file which can be opened in Excel. The cmdlet is

get-msoluser -all | export-csv c:\allusers.csv


You will now open the file. If you are deleting all of your users, make sure you at least leave behind the global administrator account. For our purposes we are deleting the user1, user2 and user3 accounts, so we will delete all other accounts from this file.



Make sure you save the file. Now we will import the file and tell Azure to delete the users that are contained in the file. You won’t see a status and if it completes it will just move back to a prompt.

import-csv c:\allusers.csv | remove-msoluser -force

If you run get-msoluser you’ll notice the accounts you requested to be deleted are now gone.


If you need to remove groups, the same logic and command structure remains. I won’t go over it in great detail but the cmdlets are

  • Get-MsolGroup –All | Export-CSV C:\Groups.csv
  • Delete Groups you might want to keep
  • Import-CSV C:\Groups.csv | Remove-MsOlGroup –Force

This is the best way I’ve found to manage multiple users, I’ve recently used this method during a large migration (5000 users, 6000 groups). The only thing I would tell you is to be patient, there are no status bars and deleting that many users can take awhile.








  1. Hello, I want to subscribe for this weblog to get newest updates, so where
    can i do it please assist.

  2. I have to express my appreciation to the writer just for rescuing me from this type of challenge. As a result of exploring through the internet and finding tricks that were not productive, I assumed my entire life was well over. Existing devoid of the solutions to the problems you’ve fixed all through your good article content is a serious case, and the ones that might have in a negative way damaged my career if I hadn’t encountered your web site. The skills and kindness in handling all the details was priceless. I don’t know what I would have done if I had not encountered such a stuff like this. I can at this point look forward to my future. Thanks for your time very much for this impressive and results-oriented help. I won’t think twice to recommend your web sites to anybody who would like tips about this subject matter.

  3. I simply wished to thank you so much once again. I’m not certain the things I would have undertaken without the actual basics documented by you concerning that area. It has been an absolute depressing setting for me, nevertheless understanding the skilled form you resolved that made me to weep over fulfillment. Extremely grateful for the service and in addition wish you find out what an amazing job your are providing teaching the others thru a site. Most probably you have never got to know any of us.

Leave a comment

Your email address will not be published.