Powershell to get the list of Disconnected mailbox in the Exchange Server

If we delete a user account then it will automatically disconnects mailbox from the account and adds to Disconnected Mailbox list. Mailbox  will be listed until retention period of 30 days

Get-MailboxStatistics -server <servername> | where { $_.DisconnectDate -ne $null } | select DisplayName,MailboxGuid,Database,DisconnectDate

Gets the list of Disconnected mailbox in the specified Exchange 2007 Server

 

Get-MailboxStatistics  | where { $_.DisconnectDate -ne $null } | select DisplayName,MailboxGuid,Database,DisconnectDate

Gets the list of Disconnected mailbox on the Exchange 2007  maibox server where you are running this command

4 thoughts on “Powershell to get the list of Disconnected mailbox in the Exchange Server

  1. This is a simple script to search for disconnected mailboxes by display name. It will prompt you to enter a portion of the display name.

    ##############################################################################################################################
    ## sean.m.simon 01/03/2013

    $in = Read-host “Enter a portion of the display name of the disconnected mailbox you are searching for. (example: Lastname, Firstname)”
    Write-Host
    Write-Host -ForeGroundColor Green “********* Searching **********”

    Get-MailboxDatabase |
    Get-MailboxStatistics |
    where {($_.DisconnectReason -ne $null) -And ($_.displayname -like “*$in*”)} |
    select displayname,LastLoggedOnUserAccount,Identity,database,DisconnectDate,disconnectreason,LastLogonTime,TotalItemSize | fl

    Write-Host -ForeGroundColor Green “********* Search Complete **********”
    Write-Host
    Write-Host ‘The following cmdlet is an example of how to reconnect a mailbox to an existing AD account:’
    Write-Host -ForeGroundColor darkcyan ‘Connect-Mailbox -Identity “a3626701-dc92-432a-9cd0-3df34b6f49af” -Database db01 -User firstname.m.lastname’
    Write-Host
    ###############################################################################################################################

    • Script Worked Perfectly

      [PS] C:\>.\Mail.Ps1
      Enter a portion of the display name of the disconnected mailbox you are searching for. (example: Lastname, Firstname): Test

      ********* Searching **********

      DisplayName : Test User A
      Identity : 882b85f5-2d18-4ced-ae92-29c3b9464db0
      Database : DB101-01
      DisconnectDate : 7/22/2014 7:04:35 AM
      DisconnectReason : Disabled
      LastLogonTime : 5/28/2014 11:15:15 AM
      TotalItemSize : 7.695 KB (7,880 bytes)

      ********* Search Complete **********

      The following cmdlet is an example of how to reconnect a mailbox to an existing AD account:
      Connect-Mailbox -Identity “a3626701-dc92-432a-9cd0-3df34b6f49af” -Database db01 -User firstname.m.lastname

      Is this possible the script iteslf determine the Identity and database from the above result and merge the things automatically to new account i.e. created recently for this SIGNUM (TestUserA)

      New-MailboxRestoreRequest -SourceDatabase “DB101-01” -SourceStoreMailbox 882b85f5-2d18-4ced-ae92-29c3b9464db0 -TargetMailbox TestUserA -ExcludeDumpster -AllowLegacyDNMismatch -TargetRootFolder “Old Mailbox Restore” –Verbose

  2. Dear Simon,

    I have accomplished the Result do

    {
    Start-Sleep -s 20

    $stat = Get-MailboxRestoreRequestStatistics -Identity $Tmbx\$ReqName

    $Status = $Stat.Status
    $PerComp = $stat.PercentComplete

    $stat | Select Status,PercentComplete

    } while (($Status -ne “Completed”) -and ($PerComp -ne 100))

    write-Host “Script Completed”

    but the result pops up after every 20 Secs as Staus Inprogress and PercentComplete as 20, 30

    Could you please assist me in create a wrtie-Progress so the output get change to below

    $Max = 100
    For($i = 1; $i -le $Max; $i++)

    {

    Write-progress -Activity “Counting I” -Status “`$i = $i” -percentcomplete ($i / $max*100) -ParentID 1

    sleep 1
    }

    Couting I
    PercentComplete 1 to 100
    [000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]

    So once the output of PercentComplete reaches 100 then it should display the merge complete.

    Percentage Progress should accompain with the command status and Percent Complete

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s