Check Size and Status of Archive Mailbox using PowerShell

Check Size and Status of Archive Mailbox using PowerShell

Archive mailbox (Online or In-Place Archive) in Office 365 provides users with additional mailbox storage space. Once the archive feature is enabled for a mailbox, the mailbox user can easily copy or move the required messages to the Online Archive folder group in Outlook Desktop and In-Place Archive in Outlook Online.

In this post, I am going to share a PowerShell script to get the size and status of Exchange Online Archive mailboxes. If you looking to find users’ primary mailbox storage size, refer to this post: Mailbox size report.

We can use the Get-Mailbox cmdlet to check the archive feature is enabled or not in a mailbox. Once we confirmed the archive status enabled, we can use Get-MailboxStatistics to get the archive mailbox size, and other mailbox related statistics data. Before proceeding, install the Exchange Online PowerShell V2 module and run the below command to connect Exchange Online Powershell.

1
Connect-ExchangeOnline

Run the following command to check the archive status for a mailbox. The property ArchiveStatus indicates the status of the archive mailbox, the value “Active” means the mailbox has an active archive mailbox.

1
Get-Mailbox
-Identity
AlexW  | Select ArchiveStatus, ArchiveDatabase

As per this post, there may be a chance ArchiveStatus is set to “None” for an active archive mailbox in Office 365, so we can also check the property is ArchiveDatabase, if this property has any value then the mailbox has an active archive mailbox.

Once you confirmed the archive status for the mailbox, run the following command to get the size and archived items count.

1
Get-MailboxStatistics
-Identity
AlexW
-Archive
| Select DisplayName, TotalItemSize, ItemCount

The parameter -Archive is the key input to get the archive mailbox. If you have not provided this property, the command simply returns the user’s primary mailbox statistics.

Find all Office 365 users with Active Archive Mailbox

Run the below command to list all the Office 365 users with archive mailbox.

1
Get-Mailbox
-Archive
-ResultSize
Unlimited | Select DisplayName, ArchiveStatus

Instead of listing only archive mailboxes, if you want to get all mailboxes with their archive mailbox status, you can run the below command.

1
Get-Mailbox
-ResultSize
Unlimited  | Select DisplayName, @{Label=
"ArchiveStatus"
;Expression={
if
(
$_
.ArchiveStatus
-eq
"Active"
-OR
$_
.ArchiveDatabase
-ne
$null
) {
"Enabled"
}
else
"Disabled"
}}}

Export Size and Status of Archive Mailbox for all Microsoft 365 users

Run the below Powershell script to get the archive status of all user mailboxes and export archive mailbox details such as archive status, archive state, mailbox size, and more.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
$Result
=@()
$mailboxes
=
Get-Mailbox
-ResultSize
Unlimited
$totalmbx
=
$mailboxes
.Count
$i
= 1
$mailboxes
|
ForEach-Object
{
$i
++
$mbx
=
$_
$size
=
$null
Write-Progress
-activity
"Processing $mbx"
-status
"$i out of $totalmbx completed"
if
(
$mbx
.ArchiveStatus
-eq
"Active"
){
$mbs
=
Get-MailboxStatistics
$mbx
.UserPrincipalName
if
(
$mbs
.TotalItemSize
-ne
$null
){
$size
=
[math]
::Round((
$mbs
.TotalItemSize.ToString().Split(
'('
)[1].Split(
' '
)[0].Replace(
','
,
''
)/1MB),2)
}
else
{
$size
= 0 }
}
$Result
+=
New-Object
-TypeName
PSObject
-Property
$(
[ordered]
@{
UserName =
$mbx
.DisplayName
UserPrincipalName =
$mbx
.UserPrincipalName
ArchiveStatus =
$mbx
.ArchiveStatus
ArchiveName =
$mbx
.ArchiveName
ArchiveState =
$mbx
.ArchiveState
ArchiveMailboxSizeInMB =
$size
ArchiveWarningQuota=
if
(
$mbx
.ArchiveStatus
-eq
"Active"
) {
$mbx
.ArchiveWarningQuota}
Else
{
$null
}
ArchiveQuota =
if
(
$mbx
.ArchiveStatus
-eq
"Active"
) {
$mbx
.ArchiveQuota}
Else
{
$null
}
AutoExpandingArchiveEnabled=
$mbx
.AutoExpandingArchiveEnabled
})
}
$Result
|
Export-CSV
"C:\Archive-Mailbox-Report.csv"
-NoTypeInformation
-Encoding
UTF8

Once you successfully run the above script, the output will be available in the Powershell object $Result. You can just filter the $Result array with Where-Object to generate further reports from this object. For example, run the below command to get details for the only archive enabled mailboxes.

1
$Result
|
Where-Object
{
$_
.ArchiveStatus
-eq
"Active"
} | Select UserName, UserPrincipalName, ArchiveMailboxSizeInMB, ArchiveWarningQuota, ArchiveQuota

Check Size and Status of Archive Mailbox using PowerShell

Comments are closed