I had a situation where I had my lab domain synched with Azure, but later I had to use the same domain for my office 365 accounts. I had a lot of funny accounts using very simple passwords, so, I didn’t want that to possibly compromise my local domain access. I then tried to delete the users, but it seems you can only do one at a time.
Enters PowerShell! In order to do that, you will need to install a couple of binaries, as stated here:
Once you have this in place, you can play a bit:
When you run the last command above, you will be prompted for credentials. Log on as a an Azure AD Admin.
Then you can see domains, users, etc:
There is a good number of commands:
What I really wanted was to be able to delete users in bunk. To avoid risks with patterns, let’s use a PowerShell feature I can’t get tired of: Out-GridView!
Isn’t it lovely?
Now, let’s add some action to it!
You can pipe it to the Remove-MsolUser cmdlet and pick the users you want to be deleted:
Get-MsolUser | Sort-Object DisplayName | Out-GridView -PassThru | Remove-MsolUser
And there: gone!
You can add the –Force to the last command just so you don’t get prompt for every user to be deleted:
This is probably very well know for office 365 users, but I thought it was worth mentioning now that Azure is becoming more and more popular.
Hope this helps!