Skip to content

Delete Microsoft 365 User Account

In this guide, you’ll learn how to delete Microsoft 365 user accounts. You will also learn how to permanently delete users and delete multiple users at once using PowerShell.

In this example, the account will be deleted and moved to the recycle bin for 30 days. After 30 days it is permanently deleted.

  1. Log into the Microsoft 365 Admin Center and go to Users > Active Users

  2. Select the account you want to delete and click the Delete user button.

    select user account

  3. If the account has a license, mailbox and OneDrive you will a few options.

    1. License: The license will be unassigned and available for other user.
    2. Make their email aliases available immediately: This option will remove any aliases on the account.
    3. Remove delegate access from their mailbox: This option will remove any delegated permissions assigned to the mailbox (send on behalf, full permissions, etc)
    4. Give another user access to the users OneDrive files for 30 days after the user is deleted
    5. Give another user access to this user’s email: This will convert the users mailbox to a shared mailbox. This is useful if you need to keep access to the users email for longer than 30 days.

    After making your selections click Delete user

    select delete options

    Depending on what you selected you will get additional instructions for completing the deletion.

    delete confirmation

That completes the steps for deleting a user.

When you delete a user in the Microsoft 365 admin center, the account is not permanently deleted right away, it is kept for 30 days in case you need to restore it. To permanently delete the user, follow the steps below.

  1. To view your deleted users go to Microsoft 365 Admin Center and go to Users > Deleted Users

    click delete users

  2. Select the account you want permanently deleted and find the User ID. The User ID is the long string of letters and numbers shown next to the email address.

    find user id

    You can also easily find the user ID with this powershell command.

    Terminal window
    Get-MgDirectoryDeletedItemAsUser -All

    find user id with powershell

  3. Open PowerShell and install Microsoft Graph (skip if you already have it install)

    Terminal window
    Install-Module -Name Microsoft.Graph -Scope CurrentUser
  4. Connect to graph

    Terminal window
    Connect-MgGraph -Scopes User.ReadWrite.All
  5. Enter the command below and change the User ID to the ID of the account you want to permanently delete.

    Terminal window
    Remove-MgDirectoryDeletedItem -DirectoryObjectId "User ID"

    remove deleted users powershell

If you need to delete multiple users at once you can use PowerShell and a csv file.

  1. Start by creating a CSV file with a UserPrincipalName column, then enter the UPN of the users you want to remove.

    Make CSV

  2. Install and connect to Microsoft Graph.

    Terminal window
    Install-Module -Name Microsoft.Graph -Scope CurrentUser
    Connect-MgGraph -Scopes User.ReadWrite.All
  3. Use the command below to soft delete all users, and be sure to update the file path to where you saved the CSV file.

    Terminal window
    $users = Import-Csv "C:\IT\DeleteUser.csv"
    foreach ($user in $users) {
    Remove-MgUser -UserId $user.UserPrincipalName
    }
  4. Those accounts will now be moved to the deleted user section in the Admin Center.

    view deleted users

  5. If you want to permanently delete the accounts instead. Use this command instead. Make sure to change the path to where your CSV is saved. (The accounts must be soft deleted before they can be permanently deleted)

    Terminal window
    foreach ($user in $deletedUsers) {
    Remove-MgDirectoryDeletedItem -DirectoryObjectId $user.Id
    }

Deleting a Microsoft 365 user removes sign-in access and associated licenses, but you need to make some decisions on how to handle the users data. Mailboxes, OneDrive content, and other data are retained or deleted based on retention policies, legal holds, and offboarding actions taken beforehand. Following a defined deletion process ensures access is revoked correctly while required data is preserved or transferred to other staff members.