<div dir="ltr" style="text-align: left;">
<div>
<div><code></code>Exchange Server is licensed by the number of mailboxes within an organization. Not only do unused Exchange mailboxes consume licenses that could be better allocated elsewhere, but unused or dormant Active Directory accounts also weaken an Exchange organization&#8217;s security. There is no native option within Exchange that retrieves a list of unused mailboxes, but PowerShell is up to the task.</div>
<div></div>
<div><span style="color: red;"><code>Get-mailbox</code> <code>-resultsize</code> <code>unlimited| </code><code>Get-MailboxStatistics</code> <code>| select displayname, lastlogontime</code></span></div>
</div>
<p>If you have a large number of mailboxes, you can send the results to a CSV file and open it in Excel to sort by the date field. To output the results to a CSV file, add Export-CSV and the file path.</p>
<div>
<div></div>
<div><span style="color: red;"><code>Get-mailbox</code> <code>-resultsize</code> <code>unlimited| </code><code>Get-MailboxStatistics</code> <code>| select displayname, lastlogontime | </code><code>Export-Csv</code> <code>C:exchinactive.csv</code></span></div>
<div></div>
<div><span style="color: red;"><code><b><span style="color: black;">Descending Order List </span></b></code></span></div>
<div><span style="color: red;"><code>get-mailboxstatistics -database yourdbname | Sort-Object LastLogonTime -Descending  ;export-csv "csvfilepath"<br /> ; ;</code></span></div>
<div>To remove disconnected mailboxes, rung following command;<br /><span style="color: red;"> Clean-MailboxDatabase dbname</span></div>
<div></div>
<div><span style="color: red;"><span style="color: black;">Have you thought of using retention policies moving forward?</span></p>
<p> <a href="http://sysadmin-talk.org/2010/04/manage-exchange-retention-policies-before-they-manage-you/" target="_blank">http://sysadmin-talk.org/2<wbr></wbr>010/04/man<wbr></wbr>age-exchan<wbr></wbr>ge-retenti<wbr></wbr>on-<wbr></wbr>policie<wbr></wbr>s-before-t<wbr></wbr>hey-manage<wbr></wbr>-you/</a></span></p>
<p><a href="http://technet.microsoft.com/en-us/library/gg181092%28v=exchg.141%29.aspx" target="_blank"><span style="color: red;">Permanently Delete a Disconnected Mailbox</span></a></div>
</div>
</div>

