O'Reilly logo

Microsoft Exchange Server 2013 PowerShell Cookbook - Second Edition by Mike Pfeiffer, Jonas Andersson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Finding inactive mailboxes

If you support a large Exchange environment, it's likely that users come and go frequently. In this case, it's quite possible over time that you will end up with multiple unused mailboxes. In this recipe, you will learn a couple of techniques used when searching for inactive mailboxes with the Exchange Management Shell.

How to do it...

The following command will retrieve a list of mailboxes that have not been logged on to in over 90 days:

$mailboxes = Get-Mailbox -ResultSize Unlimited
$mailboxes | ?{
  (Get-MailboxStatistics $_).LastLogonTime -and `
  (Get-MailboxStatistics $_).LastLogonTime -le `
  (Get-Date).AddDays(-90)
}

How it works...

You can see here that we're retrieving all of the mailboxes in the organization using ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required