O status da conta (ativado / desativado) não está acessível diretamente no EMS. Eu tive que procurar no AD para obtê-lo e vinculá-lo à caixa de correio:
#Import Exchange Module (Change this path to wherever this file lives)
Import-Module C:\Temp\Exchange.psm1
#List of Mailbox Databases
$MDBs = @("MDB01","MDB02")
ForEach ($MDB in $MDBs) {
#Get List of Mailboxes in the db
$mailboxes = Get-MailboxDatabase $MDB | Get-MailboxStatistics
#Add a semi-colon separated header line to the output file
ac C:\Temp\Mailboxes.txt "DisplayName;TotalItemSize;ItemCount;LastLogonTime;AccountStatus"
#Loop through each Mailbox and search AD to obtain account status
ForEach ($user in $mailboxes) {
#The filter ties the AD search to the specific mailbox in the loop
$Filter = "(&(objectCategory=person)(objectClass=user)(legacyExchangeDN=$($user.LegacyDN)))"
$AD = ([adsiSearcher]$Filter).findone()
#Puts the UserAccountControl attribute into readable status
#NOTE: the values I used are from my own observations to determine account status and may not be 100% accurate
if ($AD.properties.item("userAccountControl") -eq 512 -or $AD.properties.item("userAccountControl") -eq 66048) { $acct = "Enabled" }
else { $acct = "Disabled" }
#Add a line to the output file with all the info we want
ac C:\Temp\mailboxes.txt "$($user.displayname);$($user.totalitemsize);$($user.itemcount);$($user.lastlogontime);$acct"
}
}