Disable usermailbox

michael lustig 356 Reputation points
2021-09-29T12:06:55.857+00:00

Hi everyone

What is the command to see all the disable usermailbox in past?

Exchange Exchange Server Management
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Joyce Shen - MSFT 16,701 Reputation points
    2021-09-30T02:48:17.323+00:00

    Hi @michael lustig

    Are you using on-prem Exchange server or Exchange online?

    Here’s a quick Powershell win to determine who within your Exchange organisation has a mailbox and a disabled AD account.

    For on-prem users:

    $Mailboxes = Get-Mailbox | where {$_.RecipientTypeDetails -eq "UserMailbox"}  
    $Disabled = @()  
    Foreach ($Mailbox in $Mailboxes) {  
        if((Get-ADUser $Mailbox.SamAccountName).Enabled -eq $False){  
            $Disabled += Get-MailboxStatistics $Mailbox.Name | Select DisplayName,TotalItemSize  
        }      
    }  
    $Disabled | Export-Csv c:/temp/DisabledList.csv -NoTypeInformation  
    

    For cloud users:

    Connect-MsolService  
         
      $Mailboxes = Get-Mailbox | Where-Object {$_.RecipientTypeDetails -eq 'UserMailbox'}  
      $Disabled = @()  
      Foreach ($Mailbox in $Mailboxes) {  
        if((Get-msolUser -userprincipalname $Mailbox.userprincipalname).Enabled -eq $False){  
            $Disabled += Get-MailboxStatistics $Mailbox.userprincipalname | Select-Object -Property DisplayName,TotalItemSize  
        }      
      }  
      $Disabled | Export-Csv c:/temp/DisabledList.csv -NoTypeInformation  
    

    This link for your reference as well: GET DISABLED USERS WHO HAVE AN EXCHANGE MAILBOX WITH POWERSHELL
    Please Note: Since the web site is not hosted by Microsoft, the link may change without notice. Microsoft does not guarantee the accuracy of this information.


    If an Answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.