Are you using on-prem Exchange server or Exchange online?
Here’s a quick Powershell win to determine who within your Exchange organisation has a mailbox and a disabled AD account.
For on-prem users:
$Mailboxes = Get-Mailbox | where {$_.RecipientTypeDetails -eq "UserMailbox"}
$Disabled = @()
Foreach ($Mailbox in $Mailboxes) {
if((Get-ADUser $Mailbox.SamAccountName).Enabled -eq $False){
$Disabled += Get-MailboxStatistics $Mailbox.Name | Select DisplayName,TotalItemSize
}
}
$Disabled | Export-Csv c:/temp/DisabledList.csv -NoTypeInformation
For cloud users:
Connect-MsolService
$Mailboxes = Get-Mailbox | Where-Object {$_.RecipientTypeDetails -eq 'UserMailbox'}
$Disabled = @()
Foreach ($Mailbox in $Mailboxes) {
if((Get-msolUser -userprincipalname $Mailbox.userprincipalname).Enabled -eq $False){
$Disabled += Get-MailboxStatistics $Mailbox.userprincipalname | Select-Object -Property DisplayName,TotalItemSize
}
}
$Disabled | Export-Csv c:/temp/DisabledList.csv -NoTypeInformation
This link for your reference as well: GET DISABLED USERS WHO HAVE AN EXCHANGE MAILBOX WITH POWERSHELL
Please Note: Since the web site is not hosted by Microsoft, the link may change without notice. Microsoft does not guarantee the accuracy of this information.
If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.