Get-MailboxStatistics, Get-Mailbox and Archive Mailboxes (Tricks) Part 3 [Query Archive Mailboxes using PowerShell]

Check other parts:

Part 1 : Get-MailboxStatistics, Get-Mailbox and Archive Mailboxes (Tricks) Part 1

Part 2 : Get-MailboxStatistics, Get-Mailbox and Archive Mailboxes (Tricks) Part 2

In the last part of this subject, i will be talking about how to query archive data.

Which users have Archives?

(Get-Mailbox -Archive ) or (Get-Mailbox |where {$_.archivedatabase -ne $null}

[Returns the mailboxes of users who have archives. This command will not return the archive mailboxes themselves, but the main primary mailboxes for users who have archives]

Get-Mailbox -Archive -Database “Test”

[Returns the mailboxes of users in Test DB who have archives. This command will not return the archive mailboxes themselves, but the main primary mailboxes for users who have archives]

Get-Mailbox -Archive -Server MBX1

[Returns the mailboxes of users in MBX1 who have archives. This command will not return the archive mailboxes themselves, but the main primary mailboxes for users who have archives]

Get-Recipient -RecipientType ‘UserMailbox’ -Filter  ‘((ArchiveState -eq ”1”))’

[Returns (Get-Recipient) object for mailboxes having archives

Note:  To get mailboxes that are not attached to Archives, simply run your Get-Mailbox with any filters like -Database or -Server, and then pipeline it with Where {$_.archivedatabase -eq $null}

Note: The beauty thing about Get-Mailbox command is that it does not return disconnected, deleted or soft deleted mailboxes.

Note: Since Get-MailboxStatistics -Archive returns one item at a time as discussed in Part 2, then you cannot use Get-MailboxStatistics -Archive to query archives.

Note: Why running Get-MailboxStatistics |Where {$_.IsArchiveMailbox -eq $true} is not a good thing ? Because this command will return deleted archives, soft deleted archives (in case of local move request), and so it does not distinguish between active archives or not.

 

Returning all archive mailbox objects?

Two Step job :

  1. Query those primary mailboxes who have active archives using Get-Mailbox  [Since Get-Mailbox -Archive can query multiple mailboxes, but only returns the primary mailbox not its archive]
  2. Pipeline that to Get-MailboxStatistics -Archive [Since this command takes one item at a time and returns the actual archive mailbox]

So you can type something like Get-Mailbox -Archive |Get-MailboxStatistics -Archive. This command will return all mailbox archive objects in the enterprise.

Rule : Use Get-Mailbox to query and scope your result, append the archive filter to get only mailboxes with archives (either by -Archive parameter or pipeline the result with Where {$_.archivedatabase -nq $null}, and then use Get-MailboxStatistics -Archive to get the archive mailbox objects themselves.

Query Exchange Archive Mailboxes

 

2 comments on “Get-MailboxStatistics, Get-Mailbox and Archive Mailboxes (Tricks) Part 3 [Query Archive Mailboxes using PowerShell]

  1. Pingback: Get-MailboxStatistics, Get-Mailbox and Archive Mailboxes (Tricks) Part 2 | Ammar Hasayen - Blog

  2. Pingback: Get-MailboxStatistics, Get-Mailbox and Archive Mailboxes (Tricks) Part 1 | Ammar Hasayen - Blog

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