cancel
Showing results for 
Search instead for 
Did you mean: 

Need to report in all Journal Outlook Folders

Scott__Hastings
Level 5
Partner Accredited Certified

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)
                }

  ________________________________________________________________________________________________________

Scott D Hastings Sr
1 ACCEPTED SOLUTION

Accepted Solutions

GabeV
Level 6
Employee Accredited

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.

View solution in original post

1 REPLY 1

GabeV
Level 6
Employee Accredited

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.