Find Non Active Mailboxes (Powershell)

Uses Exchange 2007 Powershell cmdlets to find all the Non Active users that did not use there Mailboxes in the last 3 Months


Download the Script


 


#################################
# Exchange Non Active Users.ps1 #
# Created By Assaf Miron        #
# Date : 06/11/07               #
#################################

#################################
# Script starts here
#################################

$Header = "<h1>Non Active Users</h1><h2>(Last Logon over 3 Months)</h2>"
$LogFile = "C:\NonActiveUsers.html"
#Define CSS for the Log File
$CSS = @"<style type=`"text/css`">
TABLE{
    direction:LTR;
    border-collapse:collapse;
    border-style: solid;
    border-width: 1px;
    border-Color: Black;
    font-family: Calibri;
}
td{
    direction: LTR;
    border-style: solid;
    border-width: 1px;
    border-Color: Black;
    font-family: Calibri;
    background-repeat: no-repeat;
    background-position: center;
}
th{
    border-style: solid;
    border-width: 1px;
    border-color: Black;
}
body
{
    font-family: Calibri;
    background-repeat: no-repeat;
    background-position: top right;
}
</style>
<Title>Non Active Users</Title>"

$3Months = Get-Date
$3Months = $3Months.AddMonths(-3)
$Data = Get-MailboxStatistics -Server <ServerName> | where {$_.LastLogonTime -lt $3Months} | Select DisplayName,ItemCount,StorageLimitStatus,LastLogonTime,LastLoggedOnUserAccount,DataBase
$Data = $Data | Sort-Object -Property LastLogonTime
$Header = $Header+"<h3>There are "+$Data.Count+" Non Active Users</h3>"
$Data | ConvertTo-HTML -body $Header -Head $CSS | Out-File $LogFile

Comments