Recently, I’ve been working on trying to finish up a migration from Exchange Server 2010 to Office 365. There are potentially numerous mailboxes that aren’t used and those won’t be migrated to Office 365 because there’s no sense in paying for licensing for them.
How do you determine what mailboxes are in use?
First, use implicit remoting to load the Exchange cmdlets locally. Years ago, I would install the Exchange cmdlets locally, but it was brought to my attention that it’s unsupported, at least according to this article: Directly Loading Exchange 2010 or 2013 SnapIn Is Not Supported.
$Cred = Get-Credential $PSSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://<ExchangeServerFQDN>/PowerShell/ -Authentication Kerberos -Credential $Cred Import-PSSession -Session $PSSession
Next retrieve a list of all mailboxes with
Get-Mailbox and pipe those
I’ve silenced any warnings, otherwise the output may be littered with warnings for users who have
never logged into their mailbox. Sorting the results by
LastLogonTime in descending order places
the most recently accessed mailboxes at the top of the list. Since I’m returning more than four
properties and I want them in a table, I’ll pipe to
and specify the properties I’ve found to be the most useful.
Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics -WarningAction SilentlyContinue | Sort-Object -Property LastLogonTime -Descending | Format-Table -Property DisplayName, ItemCount, TotalItemSize, Last*
Last* for one of the properties returns the
LastLogoffTime may not always be accurate or populated. At
first, I thought the results were inaccurate due to an old account showing up with a recent
LastLoggedOnUserAccount for that account showed that someone else was
accessing it which made more sense.