Trying to find out last mailbox logon time

Running a powershell command to display users mailbox size, item count etc....and along with that the last logon and logoff time. Problem is the last logon and logoff times all say 2:00 AM or somewhere around there. After giving it a brief moment of thought, it's getting that from System Maintenance (Mailbox Assistant) which runs every night starting at 2:00 AM. How do I get the clients (the actual user) last logon for mailbox. We have some mailboxes which I know are not being used but according to my spreadsheet, I can't tell because the Mailbox Assistant is time stamping everying when it runs maintenance. Do I actually have to disable maintenance for a few days just to get a valid timestamp?
Who is Participating?
Will SzymkowskiConnect With a Mentor Senior Solution ArchitectCommented:
If you are refering to get-mailboxstatistics cmdlet this does show the mailbox size as well. When you are using Get-Aduser to reference the Logon with the get-mailboxstatistics these commands cannot be piped together to give you a single out-put.

What you can do is run both commands and simply use the -Append switch with will write to the same file and it will not overwrite previous entires.

You can script these commands together as well.
Will SzymkowskiSenior Solution ArchitectCommented:
You can use get-mailboxstatistics -identity "username" | fl which will show you the LastLoggedOnUserAccount with LastLogOffTime and LogonTime.

You can then reference that date with

Get-aduser -identity "sAMAccountName" -Properties * | fl

Reference LastLogonDate

If the mailbox is not being used you can then reference the AD account as well.


shadowtuckAuthor Commented:
That works nicely. Is there any way to incorporate this so I get mailbox sizes at the same time? Otherwise, its two separate commands with different outputs and different spreadsheets.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.