Office 365 Bulk User Delete

Hello,

I have hundreds of users that I need to delete in Office 365 and I'm trying to this by importing a CSV into Poweshell.  I've already installed the proper components here and here and I've tried following a few different guides from StackoverflowMicrosoft Technet Blogs, and even a nice script someone had already created.

For the most part everything works great.  However, I'm getting stuck on an error after running the command:

Get-MsolUser -UserPrincipalName $fila.$sColumnName |  Remove-MsolUser -Force -RemoveFromRecycleBin
Remove-MsolUser : User Not Found in the Microsoft Online directory Deleted Users container.

If I go the Office 365 web GUI and manually delete an active user and just run the command "Remove-MsolUser -Force -RemoveFromRecycleBin" it succeeds.

For some reason this command doesn't delete "Active" users.  Only "Deleted" users.  I feel like I'm missing something but every guide I come across says to do the above commands to delete users.

I have the bulk import part working.  It's reading my CSV file just fine.  It just fails with the above error.  I've read that this error can occur if the user performing the delete doesn't have "Global Admin" but I have proper permissions.

Thank you.

July 30th, 2015 10:50am

You need two different workflow to remove users from Office 365 completely (or combine it in more complex PowerShell script). First one Remove-MsolUser to remove active user account. Second one Remove-MsolUser with -RemoveFromRecycleBin parameter to remove it from deleted users (after active account removal).
  • Marked as answer by Dayrowshay 11 hours 47 minutes ago
Free Windows Admin Tool Kit Click here and download it now
July 30th, 2015 11:25am

You need two different workflow to remove users from Office 365 completely (or combine it in more complex PowerShell script). First one Remove-MsolUser to remove active user account. Second one Remove-MsolUser with -RemoveFromRecycleBin parameter to remove it from deleted users (after active account removal).
  • Marked as answer by Dayrowshay Thursday, July 30, 2015 7:46 PM
July 30th, 2015 3:24pm

Thanks! Works like a charm now.
Free Windows Admin Tool Kit Click here and download it now
July 30th, 2015 3:49pm

Hi,

It's good to know the issue has been resolved.

If you have any question about Office 365 further on, you can post it to Office 365 Community Forums:

https://community.office365.com/en-us/f/

Regards,

Melon Chen
TechNet Community Su

July 30th, 2015 11:37pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics