Powershell to determine active mailbox on Exchange Server 2010


How can we determine the number of active user in the mailbox server using Powershell ?
LVL 11
Senior IT System EngineerIT ProfessionalAsked:
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.

FOXActive Directory/Exchange EngineerCommented:
Not certain if there is an actual command to output active mailboxes but this link can get you closer to your goal.

Senior IT System EngineerIT ProfessionalAuthor Commented:

I've done it already using the Powershell script below:

Get-MailboxServer | Get-Mailbox -ResultSize Unlimited | Measure-Object

Open in new window

But how to know if the mailbox is still in use or not ?
Muhammad BurhanManager I.T.Commented:
Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

Greg BessoIT Solutions EngineerCommented:
You should try the Get-MailboxStatistics -Identity 'username' | fl * to check out the LastLogonTime and LastLogoffTime attributes that it returns.
Vaseem MohammedCommented:
check if this works
Get-Mailbox –Resultsize Unlimited | Get-MailboxStatistics | Sort LastLogonTime | select Displayname, lastlogontime

Open in new window

you can export to .csv
Get-Mailbox –Resultsize Unlimited | Get-MailboxStatistics | Sort LastLogonTime | select Displayname, lastlogontime | Export-CSV -Path d:\Mailbox-Logon-Report.csv -NoTypeInformation

Open in new window

Add additional properties to select statement as required.

Hope that helps.
Vaseem MohammedCommented:
You can also use "Date" comparison using (Get-Date).adddate(-30) and the LogonTime value to check users who has logged in last 30 days from the current date.
Senior IT System EngineerIT ProfessionalAuthor Commented:

Yes please, how to include that date older than 90 days into the script that you've suggested ?
Vaseem MohammedCommented:
Use a variable to store the value of (get-date).adddays(-90)
Compare the result in the variable to the value in lastlogontime
Logic would be, if lastlogontime is greater than value in variable then collect those user details else discard.
I can't give you a working script as am on vacation ;-)
Senior IT System EngineerIT ProfessionalAuthor Commented:
Thanks Vaseem,

let us know when you back from the vacation :-)
Vaseem MohammedCommented:
This will give you the results you are looking for.
Get-Mailbox –Resultsize unlimited -RecipientTypeDetails UserMailbox | Get-MailboxStatistics | where {$_.lastlogontime -ge ((get-date).AddDays(-90))} | Sort LastLogonTime | select Displayname, lastlogontime | Export-CSV -Path d:\Active-Mailbox-Logon-Report.csv -NoTypeInformation

Open in new window

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.