Powershell for Monitoring Journal Mailboxes

Hi Readers,

Sharing a nice little script that we have written to Monitor Exchange 2010 Journal mailboxes.

Our Goal here is :- if the Messages in the Journal mailboxes increases beyond 15000 messages

than team needs to check what is wrong with Enterprisevault, If journaling services are working fine or not.

Extract the zip file from below link, edit the .ps1 file, define the alert email & mailboxes that needs to be monitored

https://gallery.technet.microsoft.com/scriptcenter/Powershell-to-Journal-57cc1a0c

$email1 = “Vikas@labtest.com”

$from = “Systems.Monitoring@labtest.com”

$smtpserver =”smtp.labtest.com”

$JNLMbx = @(“Journal Archive01″,”Journal Archive02″,”Journal Archive03”,

“Journal Archive04″,”Journal Archive05″,”Journal Archive MP01″,”Journal Archive MP02”,

“Journal Archive MP03″,”Journal Archive MP04″,”Journal Archive MP05″,”Journal Archive MP04″,”Journal Archive MP05”)

Define the threshold for alert

if($itemc -gt “15000”)

Schedule the batch file from task scheduler (we monitor it every hour)

You can find the logging under logs folder, which will log the count of messages when script runs.

################################################################################## 
#       Author:Vikas Sukhija 
#       Reviewer:  
#       Date: 09/02/2014 
#       Description: Monitor Jopurnal Mailboxes 
################################################################################## 
 
$date = get-date -format d 
# replace \ by - 
$time = get-date -format t 
$month = get-date  
$month1 = $month.month 
$year1 = $month.year 
 
$date = $date.ToString().Replace(“/”, “-”) 
 
$time = $time.ToString().Replace(":""-"$time = $time.ToString().Replace(" """) 
 
$log1 = ".\Logs" + "\" + "JNLCount_" + $date + "_" + $time + "_.log" 
 
 
$email1 = "Vikas@labtest.com" 
$from = "Systems.Monitoring@labtest.com" 
$smtpserver ="smtp.labtest.com" 
 
 
$JNLMbx = @("Journal Archive01","Journal Archive02","Journal Archive03","Journal Archive04""Journal Archive05","Journal Archive MP01","Journal Archive MP02","Journal Archive MP03""Journal Archive MP04","Journal Archive MP05","Journal Archive MP04","Journal Archive MP05") 
 
##############ADD Exchange Shell ################################################ 
 
If ((Get-PSSnapin | where {$_.Name -match "Microsoft.Exchange.Management.PowerShell.E2010"}) -eq $null) 
{ 
    Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 
} 
 
$JNLMbx | foreach-object { 
 
$itemc = (Get-MailboxStatistics $_).itemcount 
 
if($itemc -gt "15000") 
   { 
    Write-host "Count for $_ is $itemc" -foregroundcolor Red 
    Add-content $log1 "Count for $_ is $itemc" 
        $subject = "Event Notification : OPEN CRITICAL : Count for $_ is $itemc" 
    $message = new-object Net.Mail.MailMessage 
    $smtp = new-object Net.Mail.SmtpClient($smtpserver) 
    $message.From = $from 
    $message.To.Add($email1) 
    $message.subject = $subject 
        $smtp.Send($message) 
 
   } 
else 
   { 
 
   Write-host "Count for $_ is $itemc" -foregroundcolor Green 
   Add-content $log1 "Count for $_ is $itemc" 
    
   } 
 
} 
 
##################################################################################
Regards
Sukhija Vikas

http://msexchange.me

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s