Office 365 – Can’t delete an external account from the recycle bin?

Came across this today on a customers site.  Basically there was a need to delete an external users account from Office 365 AD.  According to this MS article the process is pretty straight forward.

However when I come to delete the account using the PowerShell below….

Remove-MsolUser -UserPrincipalName ‘’ -RemoveFromRecycleBin

…I hit an error:

Remove-MsolUser : User Not Found.  ‘’

I knew this was rubbish as I could see it when I ran the command:

Get-MsolUser –ReturnDeletedUsers

The odd thing was I could delete normal Office 365 accounts with no issues, the article here didn’t help

So, how to fix.

Run the command

Get-MsolUser –ReturnDeletedUsers  | select UserPrincipalName, ObjectId

You’ll now have a objectID related to the email you’re trying to delete.  Use this objectID to remove the account

RemoveMsolUser RemoveFromRecycleBin ObjectId <objected>

Hey-presto the account is removed.

Argh! IT is fun sometimes.

Leave a Reply

Your email address will not be published. Required fields are marked *