Exchange Server Share

… Information sharing on Exchange Server …

Exchange Powershell Tip #04

leave a comment »

Exchange Powershell Tip #04

How to find all inactive mailboxes in Exchange 2010 or 2013 environment?

OR

How to get the list of all mailboxes which are not accessed in last X days?

You can get the list of all the mailboxes which are not accessed in last 90 days by using below cmdlet on the screen.

Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | Where{$_.Lastlogontime -lt (Get-Date).AddDays(-90)} | Select DisplayName, LastLoggedOnUserAccount, LastLogonTime

Change the days from 90 to 180, 365 or whatever you want in AddDays(-90).

You can export the result to csv file by adding pipe to Export-CSV

Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | Where{$_.Lastlogontime -lt (Get-Date).AddDays(-30)} | Select DisplayName, LastLoggedOnUserAccount, LastLogonTime | Export-csv C:\Temp\InactiveUsers.csv

 

Now question is, how to get the list of all mailboxes which are not accessed at all? Use below cmdlet to get the list.

Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | Where{$_.Lastlogontime -eq $Null} | Select DisplayName, LastLogonTime | Export-csv C:\Temp\InactiveUsers.csv

But using above cmdlet you may find that list includes all the mailboxes which are created recently and new users/employees of your company might be joining the firm in future date. In that case we can add a column to find out when the mailbox is actually created so you would be able to filter those mailboxes.

Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | Where{$_.Lastlogontime -eq $Null} | Select DisplayName, LastLogonTime, @{Name=”WhenMailboxCreated”;Expression={(Get-Mailbox $_).WhenMailboxCreated}} | Export-csv C:\Temp\InactiveUsers.csv

==> Get All Exchange Powershell Tips from the Archive Here<==

Written by Amit Tank

May 25, 2016 at 5:00 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: