Powershell to determine active mailbox on Exchange Server 2010

Senior IT System Engineer
Senior IT System Engineer used Ask the Experts™
on
People,

How can we determine the number of active user in the mailbox server using Powershell ?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
FOXActive Directory/Exchange Engineer
Top Expert 2015
Commented:
Not certain if there is an actual command to output active mailboxes but this link can get you closer to your goal.

https://exchangeserverpro.com/counting-exchange-server-2010-mailboxes-powershell/

Author

Commented:
@Fox,

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.
Top Expert 2015
Commented:
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Greg BessoIT Solutions Engineer

Commented:
You should try the Get-MailboxStatistics -Identity 'username' | fl * to check out the LastLogonTime and LastLogoffTime attributes that it returns.
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.
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.

Author

Commented:
@Vaseem,

Yes please, how to include that date older than 90 days into the script that you've suggested ?
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 ;-)

Author

Commented:
Thanks Vaseem,

let us know when you back from the vacation :-)
Hi,
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

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial