Link to home
Start Free TrialLog in
Avatar of Albert Widjaja
Albert WidjajaFlag for Australia

asked on

Powershell to determine active mailbox on Exchange Server 2010

People,

How can we determine the number of active user in the mailbox server using Powershell ?
SOLUTION
Avatar of FOX
FOX
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Albert Widjaja

ASKER

@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 ?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
@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 ;-)
Thanks Vaseem,

let us know when you back from the vacation :-)
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial