Created
April 3, 2016 15:42
-
-
Save rdtechie/45232e0345420c85fe96c780f3c461ac to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#requires -Version 2 | |
#requires -PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn | |
$xDays = 90 | |
Get-Mailbox -ResultSize Unlimited -RecipientTypeDetails UserMailbox | | |
ForEach-Object -Process { | |
$MailboxStats = Get-MailboxStatistics -Identity $_.DistinguishedName | |
$si = Get-MailboxFolderStatistics -Identity $_.DistinguishedName -IncludeOldestAndNewestItems -FolderScope SentItems | |
if($si.NewestItemReceivedDate -AND (New-TimeSpan -Start $si.NewestItemReceivedDate.ToLocalTime()).Days -ge $xDays) { | |
New-Object -TypeName PSObject -Property @{ | |
Name = $_.Name | |
Alias = $_.Alias | |
PrimarySmtpAddress = $_.PrimarySmtpAddress | |
WhenCreated = $_.WhenCreated | |
Database = $_.Database | |
LastSentItemDate = $si.NewestItemReceivedDate | |
LastLogonTime = $si.LastLogonTime | |
MailboxSize = $MailboxStats.totalitemsize.Value.ToMB() | |
} | |
} | |
} | | |
Select-Object -Property Name, Alias, PrimarySmtpAddress, LastSentItemDate, WhenCreated, LastLogonTime, Database | | |
Sort-Object -Property LastSentItemDate | | |
Export-Csv -Path C:\temp\Inactive90Days.csv -NoTypeInformation -UseCulture |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment