Need to Extract email address from all disabled mailboxes across multiple databases in Exchange 2013.

CoP 5 Reputation points
2025-11-25T19:18:20.4666667+00:00

Hi Everyone,

I have been asked to provide a listing of all users that have been disabled (in Exchange terms), across multiple databases with the following output: DisplayName,PrimarySmtpAddress,TotalItemSize,LastLogonTime

As these users are already disabled (in Exchange terms) they currently no longer have mailbox attributes assigned to their AD accounts; so I don't believe Get-Mailbox (for the email address will work). However, I have been able to get the other items: DisplayName, TotalItemSize, and LastLogonTIme.

Here is my PS script:

$dbs = Get-MailboxDatabase 
$dbs | foreach {Get-MailboxStatistics -Database $_.DistinguishedName} | where {$_.DisconnectReason -eq "Disabled"} | FT DisplayName,TotalItemSize,LastLogonTime

I trying to get the email address from each mailbox within $dbs, but the only command to get it (I believe) is the Get-Mailbox command.

Any suggestions would be greatly appreciated.

Exchange | Exchange Server | Other
Exchange | Exchange Server | Other
A robust email, calendaring, and collaboration platform developed by Microsoft, designed for enterprise-level communication and data management.Miscellaneous topics that do not fit into specific categories.
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Q&A Assist
    2025-11-25T19:18:32.9366667+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    To extract the email addresses from disabled mailboxes in Exchange 2013, you can use the Get-MailboxStatistics cmdlet to get the necessary information about the disabled mailboxes, but since the mailboxes are disabled, you won't be able to retrieve the email addresses directly using Get-Mailbox. However, you can still obtain the email addresses by correlating the disabled mailboxes with their respective Active Directory user accounts.

    Here’s a modified PowerShell script that combines the information from Get-MailboxStatistics and Get-ADUser to retrieve the email addresses:

    # Get all mailbox databases
    $dbs = Get-MailboxDatabase 
    
    # Initialize an array to hold results
    $results = @()
    
    # Loop through each database
    foreach ($db in $dbs) {
        # Get disabled mailbox statistics
        $disabledMailboxes = Get-MailboxStatistics -Database $db.DistinguishedName | Where-Object {$_.DisconnectReason -eq "Disabled"}
        foreach ($mailbox in $disabledMailboxes) {
            # Get the corresponding AD user
            $adUser = Get-ADUser -Identity $mailbox.DisplayName -Properties EmailAddress
            # Create a custom object to hold the information
            $result = [PSCustomObject]@{
                DisplayName = $mailbox.DisplayName
                PrimarySmtpAddress = $adUser.EmailAddress
                TotalItemSize = $mailbox.TotalItemSize
                LastLogonTime = $mailbox.LastLogonTime
            }
            # Add the result to the array
            $results += $result
        }
    }
    
    # Output the results
    $results | Format-Table DisplayName, PrimarySmtpAddress, TotalItemSize, LastLogonTime
    

    Explanation:

    • This script retrieves all mailbox databases and iterates through each one to find disabled mailboxes.
    • For each disabled mailbox, it uses Get-ADUser to fetch the email address associated with the user account.
    • Finally, it constructs a custom object containing the display name, primary SMTP address, total item size, and last logon time, which is then outputted in a formatted table.

    Make sure you have the necessary permissions to run these commands and access Active Directory information.


    References:


  2. Vergil-V 7,555 Reputation points Microsoft External Staff Moderator
    2025-11-26T04:54:02.9766667+00:00

    Hi @CoP 
    Thank you for reaching out to Microsoft Learn Q&A!  
    As a forum moderator, I don’t have access to a testing environment to replicate specific user scenarios. My support is primarily based on official documentation and insights shared by other members. I’m happy to share what I’ve discovered so far from my research. 

    After disabling a mailbox using the Disable-Mailbox cmdlet or through the EAC, all Exchange attributes including the primary SMTP address are removed from Active Directory. undefined

    This means the user is no longer a UserMailbox. You can confirm this by checking the RecipientType property. 

    undefined

    References: 

    To retrieve the SMTP address, you may consider these options: 

    • Note the primary SMTP address before disabling the mailbox. 
    • Reconnect the disabled mailbox. 
    • Retrieve the SMTP address from tracking logs that store this information. 

    I understand this may not be the exact answer you were hoping for, but I hope it provides some useful insight. Please don’t hesitate to reply if you have any updates. 

    Thank you for your understanding. 


    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' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.