Midlands Technology Centre, Broadlands, Wolverhampton Business Park, WV10 6TA
0845 241 6370 info@msvconsultancy.co.uk
Enable, Entrust & Educate Through IT

Office 365 – Not all selected users were deleted error

Office 365 – Not all selected users were deleted error

Hi All,

One of our customers recently had a user leave the company, but wanted to retain their mailbox data in the form of a Shared Mailbox (so that it did not consume an Office 365 licence).

The issue with Office 365 is that if you remove a licence from a user, it automatically deletes the associated mailbox!

To work around this, the user's mailbox data was exported to PST, a new Shared Mailbox created, and then the PST data was re-imported back into said Shared Mailbox.

Once done, the user's SMTP address was changed, and the Shared Mailbox SMTP address was changed to that of the email address of the user, meaning all future new email would continue to flow into the Shared Mailbox.

The problem with doing it this way is that although the Shared Mailbox works fine for external users, the old user object now can't be deleted within the portal as the following error is received


Not all selected users were deleted

Some users can’t be deleted because they are managed with a service other than Office 365. You need to remove all licenses associated with the user and then delete the user.


The Solution

Unfortunately the only way to delete the user is to connect to Office 365 via PowerShell by running the following commands in turn:-


  1. Set-ExecutionPolicy remotesigned
  2. $LiveCred = Get-Credential
  3. $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $LiveCred -Authentication Basic -AllowRedirection
  4. Connect-Msolservice
  5. Remove-MsolUser -UserPrincipalName <account id>
  6. Remove-MsolUser -UserPrincipalName <account id> -RemoveFromRecycleBin


Going forward, converting the mailbox from user to shared with the following commands is probably the best way to achieve the desired result (after you have taken a PST backup first of course):-


  1. Get-Mailbox -identity user@domain.com | set-mailbox -type “Shared”
  2. Set-Mailbox  user@domain.com -ProhibitSendReceiveQuota 10GB -ProhibitSendQuota 9.75GB -IssueWarningQuota 9.5GB
  3. Add-MailboxPermission user@domain.com-User "OtherUser" -AccessRights FullAccess
  4. Connect-MsolService
    $VARIABLE = (Get-MSOLUser -UserPrincipalName user@domain.com).Licenses[0].AccountSkuId
    Set-MsolUserLicense -UserPrincipalName user@domain.com -RemoveLicenses $VARIABLE


NB - Shared mailbox sizes increased from 5GB to 10GB last year.



Hope this helps.



No Comments Yet.

Leave a comment