Exchange mailbox database disabled accounts cmdlet

Hello, I have 10 databases in my Exchange Server, and I'm trying to get only the COUNT of the number of disabled mailboxes in ONE DATABASE. I'm able to get the TOTAL amount of 10 disabled/Active databases total, but I need to get the COUNT of disabled mailboxes PER database. Any ideas how I can get this?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Todd NelsonSystems EngineerCommented:
What command are you running?  Please provide as a reference.
mleeAuthor Commented:
So this cmdlet works but it gets me the TOTAL number of disabled accounts out of all mailbox databases:
(Get-aduser –filter *|where {$_.enabled –eq “True”}).count

This command gets me no output:
Get-MailboxDatabase <Database Name>|Get-MailboxStatistics |Where {$_.DisconnectReason –eq “Disabled

This command gives output, but only 0:
(Get-MailboxStatistics –Database <Database Name>|where {$_.DisconnectDate –ne $null}).count

I tried this command as well but no output:
foreach ($DB in $DBs) {Get-MailboxStatistics –Database $DB | where {$_.DisconnectDate –ne $null } | select Database.DisplayName.DisconnectDate,@{n=”MemberCount”;e={(Get-MailboxStatistics –Database $DB | where { $_.DisconnectDate-ne $null } ).Count}}}

I need to get the COUNT of disabled accounts PER Database. I've been working on this for over a week and still can't figure it out. Any help would be great.

Todd NelsonSystems EngineerCommented:
Going off of the first command that you stated didn't provide output, try this...

Get-MailboxDatabase | Get-MailboxStatistics | Where {$_.DisconnectReason -eq "Disabled"} | select DisplayName, ServerName, DatabaseName | Export-Csv -NoType C:\Temp\Disconnected.csv

Open in new window

The second command should provide the number for disconnected mailboxes for the database you specified.  If none in that DB, then yes the count will be zero.

(Get-MailboxStatistics -Database "DB_Name" | where {$_.DisconnectDate -ne $null}).count

Open in new window

I'm not going to try any further with the third.  But I do know it is incomplete.

Personally, I prefer the commands that output to CSV files (the first command I provided) because they tend to be less confusing and can provide all the output data needed for better analysis.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.