11-11-2013 08:43 AM
I use this script to report on the number of items and age in the Journal Inbox,
Can someone provide guidance on adding "Failed to Store" Failed to Copy" etc?
________________________________________________________________________________________________________
#requires -version 1
Set-PSDebug -Strict
#If (-Not Get-PSSnapin.Contains('Microsoft.Exchange.Management.PowerShell.E2010')) {
# Add-PSSnapin 'Microsoft.Exchange.Management.PowerShell.E2010' -ErrorAction 'Stop'
#}
$exchangeSnapinFound = $False
Get-PSSnapin |
ForEach {
If ($_.Name -EQ 'Microsoft.Exchange.Management.PowerShell.E2010') {
$exchangeSnapinFound = $True
}
}
If (-Not $exchangeSnapinFound) {
#.$env:ExchangeInstallPath\bin\RemoteExchange.ps1
Add-PSSnapin 'Microsoft.Exchange.Management.PowerShell.E2010' -ErrorAction 'Stop'
}
.$env:ExchangeInstallPath\bin\RemoteExchange.ps1
##Requires -pssnapin Microsoft.Exchange.Management.PowerShell.E2010
$smtpServer = "server"
$smtpSender = "svcexchops@xxx.com"
$smtpRecipients3 = "receiver@xxx.com"
$smtpRecipients1 = "receiver@xxx.com"
#$smtpRecipients2 = "receiver@xxx.com"
$smtpRecipients2 = "receiver@xxx.com"
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$folder = get-mailboxfolderstatistics EVS_EXH2k10Jrn1 -FolderScope Inbox -IncludeOldestAndNewestItems
$date = $(get-date).ToUniversalTime()
If ($folder.OldestItemReceivedDate -ne $null)
{
$t1kw2 = new-timespan $folder.OldestItemReceivedDate $date
}
Else
{$t1kw2 = new-timespan -hour 1}
#$date = $(get-date).ToUniversalTime()
#$t1kw2 = new-timespan $folder.OldestItemReceivedDate $date
# the value for $t1kw3 is the threshold - currently set to 1 hours
$t1kw3 = new-timespan -hour 1
if ($t1kw2 -gt $t1kw3)
{
$t1results1 = $t1kw2
$t1results2 = "The oldest item in the Journal mailbox is " + $t1results1 + " old. `(HH`:MM`:SS.xxxxxxx`)"
$t1results = $t1results2
$smtp.Send($smtpSender,$smtpRecipients1,"ALERT -EVS_EXH2k10Jrn1 Aged Items",$t1results)
# Write-Host $t1results2
}
else
{}
if ($folder.ItemsInFolder -gt 30000)
{
$t2results1 = $folder.ItemsInFolder
$t2results2 = "The current journal mailbox count is at " + $t2results1
$t2results = $t2results2
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$smtp.Send($smtpSender,$smtpRecipients3,"Major ALERT - EVS_EXH2k10Jrn1",$t2results)
}
elseif ($folder.ItemsInFolder -gt 15000)
{
$t2results1 = $folder.ItemsInFolder
$t2results2 = "The current journal mailbox count is at " + $t2results1
$t2results = $t2results2
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$smtp.Send($smtpSender,$smtpRecipients2,"ALERT - EVS_EXH2k10Jrn1",$t2results)
}
else
{
$t2results1 = $folder.ItemsInFolder
$t2results2 = "The current journal mailbox count is at " + $t2results1
$t2results = $t2results2
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$smtp.Send($smtpSender,$smtpRecipients1,"ALERT - EVS_EXH2k10Jrn1",$t2results)
}
________________________________________________________________________________________________________
Solved! Go to Solution.
11-11-2013 10:54 AM
Hi Scott,
I think you need to change this line:
$folder = get-mailboxfolderstatistics EVS_EXH2k10Jrn1 -FolderScope Inbox -IncludeOldestAndNewestItems
since you can only pull certains system folders using the -FolderScope parameter. You could add something like this:
$folders=Get-MailboxFolderStatistics EVS_EXH2k10Jrn1 -IncludeOldestAndNewestItems foraech($folder in $folders) { if (($folder.Name -eq 'Failed to Store') -or ($folder.Name -eq 'Failed to Copy' ...)) { #Add your code } }
I hope this helps.
11-11-2013 10:54 AM
Hi Scott,
I think you need to change this line:
$folder = get-mailboxfolderstatistics EVS_EXH2k10Jrn1 -FolderScope Inbox -IncludeOldestAndNewestItems
since you can only pull certains system folders using the -FolderScope parameter. You could add something like this:
$folders=Get-MailboxFolderStatistics EVS_EXH2k10Jrn1 -IncludeOldestAndNewestItems foraech($folder in $folders) { if (($folder.Name -eq 'Failed to Store') -or ($folder.Name -eq 'Failed to Copy' ...)) { #Add your code } }
I hope this helps.