Skip to content
This repository was archived by the owner on Jul 25, 2018. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions Find-MailboxDelegates.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -734,18 +734,27 @@ Begin{
$user = get-user $item.user -erroraction SilentlyContinue

If(![string]::IsNullOrEmpty($user.WindowsEmailAddress)){
$mbStats = Get-MailboxStatistics $user.WindowsEmailAddress.tostring() | select totalitemsize
If($mbStats.totalitemsize.value)

#Mailbox size for user
$mbStats = (Get-MailboxStatistics $user.WindowsEmailAddress.tostring()).totalitemsize.value

#Add mailbox size for archive mailbox if present
If((Get-Mailbox $user.WindowsEmailAddress.tostring()).ArchiveDatabase -ne $null) {
$mbStatsArchive = (Get-MailboxStatistics $user.WindowsEmailAddress.tostring() -Archive).totalitemsize.value
$mbStats += $mbStatsArchive
}

If($mbStats)
{
#if connecting through remote pshell, and not using Exo server shell, the data comes as
#TypeName: Deserialized.Microsoft.Exchange.Data.ByteQuantifiedSize
if ( ($mbStats.TotalItemSize.Value.GetType()).name.ToString() -eq "ByteQuantifiedSize")
if ( ($mbStats.GetType()).name.ToString() -eq "ByteQuantifiedSize")
{
$mailboxSize = $mbStats.totalitemsize.value.ToMb()
$mailboxSize = $mbStats.ToMb()
}
else
{
$mailboxSize = $mbStats.TotalItemSize.Value.ToString().split("(")[1].split(" ")[0].replace(",","")/1024/1024
$mailboxSize = $mbStats.ToString().split("(")[1].split(" ")[0].replace(",","")/1024/1024
}

}
Expand Down