Hi

I used a somewhat other approach to get a list of unused mailboxes.
This uses the folder statistics to make a list of mailboxes that have emails in 
sent items older than $xDays. Sending emails was for the scenario I needed this 
a better definition whether a mailbox was still used or not.
I found this script somewhere sometime, so can’t take full credit for it. But 
I’ve edited it to suit my needs and display additional properties I found 
relevant.
In the example below, you’ll get a list of all mailboxes that have not sent 
emails for 365 days (assuming there’s no policy active on mailboxes that 
archives/deletes emails after x days…)


________________________________
$xDays = 365

$mailboxes = Get-Mailbox -ResultSize Unlimited -RecipientTypeDetails UserMailbox
$mailboxes | Foreach-Object {


   $si = Get-MailboxFolderStatistics $_ -IncludeOldestAndNewestItems 
-FolderScope SentItems
   $inbox = Get-MailboxFolderStatistics $_ -IncludeOldestAndNewestItems 
-FolderScope Inbox
   $mbstats = Get-MailboxStatistics $_

   if($si.NewestItemReceivedDate -AND (New-TimeSpan 
$si.NewestItemReceivedDate.ToLocalTime()).Days -ge $xDays)
   {
        New-Object PSObject -Property @{
         Name = $_.DisplayName
         Alias = $_.Alias
         LastSentItemDate = $si.NewestItemReceivedDate
        LastInboxItemDate = $inbox.NewestItemReceivedDate
         WhenChanged = $_.WhenChanged
         LastLogonTime = $mbstats.LastLogonTime
         LastLoggedonUser = $mbstats.LastLoggedOnUserAccount
       }
   }

} | FT 
Name,Alias,LastLoggedOnUser,LastLogonTime,WhenChanged,LastInboxItemDate,LastSentItemDate
________________________________

Kind regards,

Stephan Schwarz
System Administrator @ Leiden University Medical Center

[social-facebook-box-blue-icon]<http://www.facebook.com/stephan.schwarz.0>[social-linkedin-box-blue-icon]<http://www.linkedin.com/pub/stephan-schwarz/23/911/695>[social-twitter-box-blue-icon]<http://twitter.com/#!/Schwarz_Stephan>[RSS-icon]<http://www.stephan-schwarz.net/?feed=rss2>[www-page-icon]<http://www.stephan-schwarz.net/>
Tel.: +31 (0)6-4662-8977
Email:   m...@stephan-schwarz.net<mailto:m...@stephan-schwarz.net>


From: listsad...@lists.myitforum.com [mailto:listsad...@lists.myitforum.com] On 
Behalf Of Daniel Chenault
Sent: Wednesday, February 19, 2014 10:46 PM
To: scripting@lists.myitforum.com
Subject: Re: [scripting] list inactive mailboxes

Get-mailbox and filter on lastloggedon. Up to you to define what "inactive" 
means

On Feb 19, 2014, at 10:42, jlos...@mpi.mb.ca<mailto:jlos...@mpi.mb.ca> wrote:
Hi, does anyone have a script that will list all my inactive exchange 2010 
mailboxes?


Thanks,

Jason Loster
Senior IT Analyst
IT Security, Compliance and Risk Management
Manitoba Public Insurance
708-234 Donald St.
Winnipeg, MB, R3C 4A4
jlos...@mpi.mb.ca<mailto:jlos...@mpi.mb.ca>






<<inline: image001.png>>

<<inline: image002.png>>

<<inline: image003.png>>

<<inline: image004.png>>

<<inline: image005.png>>

Reply via email to