on 05-20-2013 10:34 PM
Have you ever looked inside an Exchange journal mailbox after it's been targeted with Enterprise Vault? If you have never opened your Enterprise Vault journal mailbox with Outlook, then you should! In this article I'll give a brief list of the folders that the mailbox may contain and what they mean to the health of your Enterprise Vault journaling environment.
Excellent post, thanks Wayne!
We have a VBScript that runs a couple of times a day and emails a report that contains the total number of items (and MB used) in the mailbox as well as listing each (sub) folder with the number of messages in it.
We typically see DL Expansion, Invalid Journal Report, and Failed to Copy issues.
Thanks for sharing the article Wayne.
Hi Tony, can you share that script here for the benefits of the team ?
for what it's worth, you should be able to accomplish this with the get-mailbox and get-mailboxfolderstatistics powershell commands. you could have the results emailed or piped to a file and stored somewhere.
Thank you for your sharing!
Great post!
Thanks for sharing.
I didn't write this and I'm not sure where i originally found it (maybe scriptingguys?). It's not very pretty but works...good luck!
Output looks something like this:
Mailbox - JournalMBX
Top of Information Store
-- Conversation Action Settings : 0
-- Deleted Items : 0
-- Enterprise Vault Journaling Service : 0
---- Failed DL Expansion : 5
---- Failed to copy : 3
---- Failed to store : 0
---- Invalid Journal Report : 10
-- Inbox : 37
-- Junk E-Mail : 0
-- RSS Feeds : 0
-- Sent Items : 0
Storage Used in Mailbox - JournalMBX (msgs): 60 (bytes): 6,144,457
Code to send email message with file, note you will need to redirect the output or modify the script to output to a file rather than the console. We email the report a couple of times a day to monitor the number of messages in the mailbox.
ToAdd = "user1@foo.com;user2@foo.com"
FromAdd = admin@foo.com
SMTPServer = "smtp.foo.com"
ServerSubject = ("Journal Repository Mailbox Count")
MsgBody = ("Journal Repository Mailbox Status") & vbcrlf & vbcrlf
MsgBody = MsgBody & CreateObject("Scripting.FileSystemObject").OpenTextFile("C:\Status\JournalMBX-Status.txt", 1).ReadAll
Set objEmail = CreateObject("CDO.Message")
objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = SMTPServer
objEmail.From = FromAdd
objEmail.To = ToAdd
objEmail.Subject = ServerSubject
objEmail.Textbody = MsgBody
objEmail.AddAttachment "C:\Status\JournalMBX-Status.txt"
objEmail.Configuration.Fields.Update
objEmail.Send
Here's the code to generate the report. You might need to run cscript.exe from c:\windows\syswow64\
' USAGE: cscript ProcessNotesEmails.vbs SERVERNAME MAILBOXNAME
' This requires that CDO 1.21 is installed on the computer.
Dim rc, strDate, strLogFile, Level
'Get date/time formatted as YYYYMMDD_HHMMSS
strDate= Year(Now) & Right(Month(Now)+100, 2) & Right(Day(Now)+100, 2) & "_" & Right(Hour(Now)+100, 2) & Right(Minute(Now)+100, 2) & Right(Second(Now)+100, 2)
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' START OF USER CONFIGURABLE VARIABLES '''''''''''''''''''''''''''''''''''''''''''''
strLogFile="C:\temp\chk-ev-myvault.log"
' END OF USER CONFIGURABLE VARIABLES '''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
PrintLog "Starting script"
' Get command line arguments.
Dim obArgs
Dim cArgs
Set obArgs = WScript.Arguments
cArgs = obArgs.Count
Main
Sub Main()
Dim oSession
Dim oInfoStores
Dim oInfoStore
Dim oInfoStore2
Dim oRootFolder
Dim oFolders
Dim StorageUsed
Dim NumMessages
Dim strProfileInfo
Dim sMsg
' On Error Resume Next
'Open log file
'Append to log file
'
Dim oFSO, oFile
Dim strData
Dim strPattern, strReplace
Dim strD
Const ForAppending = 8
strD = FormatDateTime(Now(),0)
Set oFSO = CreateObject("Scripting.FileSystemObject")
' If NOT oFSO.FileExists(strLogFile) Then
Set oFile=oFSO.CreateTextFile(strLogFile)
' End If
oFile.WriteLine strD & " - " & "End of Run"
If cArgs <> 2 Then
printlog( "Usage: cscript script.vbs SERVERNAME MAILBOXNAME")
printlog( " e.g. cscript script.vbs svr smitha")
Exit Sub
End If
'Create Session object.
Set oSession = CreateObject("MAPI.Session")
if Err.Number <> 0 Then
sMsg = "Error creating MAPI.Session."
sMsg = sMsg & "Make sure CDO 1.21 is installed. "
sMsg = sMsg & Err.Number & " " & Err.Description
printlog( sMsg)
Exit Sub
End If
strProfileInfo = obArgs.Item(0) & vbLf & obArgs.Item(1)
'Log on.
oSession.Logon , , False, True, , True, strProfileInfo
if Err.Number <> 0 Then
sMsg = "Error logging on: "
sMsg = sMsg & Err.Number & " " & Err.Description
printlog( sMsg)
printlog( "Server: " & obArgs.Item(0))
printlog( "Mailbox: " & obArgs.Item(1))
Set oSession = Nothing
Exit Sub
End If
'Grab the information stores.
Set oInfoStores = oSession.InfoStores
if Err.Number <> 0 Then
sMsg = "Error retrieving InfoStores Collection: "
sMsg = sMsg & Err.Number & " " & Err.Description
printlog( sMsg)
printlog( "Server: " & obArgs.Item(0))
printlog( "Mailbox: " & obArgs.Item(1))
Set oInfoStores = Nothing
Set oSession = Nothing
Exit Sub
End If
'Loop through information stores to find the user's mailbox.
For Each oInfoStore In oInfoStores
If InStr(1, oInfoStore.Name, "Mailbox - ", 1) <> 0 Then
'&HE080003 = PR_MESSAGE_SIZE
StorageUsed = oInfoStore.Fields(&HE080003)
if Err.Number <> 0 Then
sMsg = "Error retrieving PR_MESSAGE_SIZE: "
sMsg = sMsg & Err.Number & " " & Err.Description
printlog( sMsg)
printlog( "Server: " & obArgs.Item(0))
printlog( "Mailbox: " & obArgs.Item(1))
Set oInfoStore = Nothing
Set oInfoStores = Nothing
Set oSession = Nothing
Exit Sub
End If
'&H33020003 = PR_CONTENT_COUNT
NumMessages = oInfoStore.Fields(&H36020003)
if Err.Number <> 0 Then
sMsg = "Error Retrieving PR_CONTENT_COUNT: "
sMsg = sMsg & Err.Number & " " & Err.Description
printlog( sMsg)
printlog( "Server: " & obArgs.Item(0))
printlog( "Mailbox: " & obArgs.Item(1))
Set oInfoStore = Nothing
Set oInfoStores = Nothing
Set oSession = Nothing
Exit Sub
End If
ProcessMailbox(oInfoStore)
sMsg = "Storage Used in " & oInfoStore.Name & space(40 - len(oInfoStore.Name))
sMsg = sMsg & " (msgs): " & space(6 - len(FormatNumber(NumMessages,0,,-1))) & FormatNumber(NumMessages,0,,-1) & " (bytes): " & FormatNumber(StorageUsed,0,,-1)
' printlog( sMsg)
' printlog( "Number of Messages: " & NumMessages)
WScript.echo sMsg
' WScript.echo "Number of Messages: " & FormatNumber(NumMessages,0,,-1)
End If
Next
' Log off.
oSession.Logoff
' Clean up memory.
Set oInfoStore = Nothing
Set oInfoStores = Nothing
Set oSession = Nothing
oFile.WriteLine strD & " - " & "End of Run"
oFile.Close
End Sub
Sub ProcessMailbox(oIS)
WScript.echo oIS.Name
WScript.echo oIS.RootFolder.Name
For Each oF in oIS.RootFolder.Folders
'Process top-level folders
'Ignore non message folders?
'If Name in ("Journal, Contacts, etc") then continue.
If oF.Name = "Calendar" OR oF.Name = "Contacts" OR oF.Name = "Drafts" _
OR oF.Name = "Tasks" OR oF.Name = "Notes" OR oF.Name = "Outbox" _
OR oF.Name = "Journal" OR oF.Name = "Calendar Attachments" Then
printlog ("Skipping: " & oIS.Name & "/" & oF.Name)
Else
' printlog( "Processing: " & oIS.Name & "/" & oF.Name)
Level = 0
ProcessFolder(oF)
End If
Next
End Sub
Sub ProcessFolder(StartFolder)
Dim objFolder
Dim objItem
Dim iCount
Level = Level + 1
' printlog( " " & StartFolder.Name)
iCount=0
For Each objItem In StartFolder.Messages
iCount=iCount+1
Next
WScript.Echo String(Level*2,"-") & " " & StartFolder.Name & " : " & FormatNumber(iCount,0,,-1)
' process all the subfolders of this folder
For Each objFolder In StartFolder.Folders
Call ProcessFolder(objFolder)
Next
'End If
Level = Level - 1
Set objFolder = Nothing
End Sub
Sub printlog(strMessage)
Dim strD
strD = FormatDateTime(Now(),0)
' oFile.WriteLine strD & " - " & strMessage
' Wscript.Echo strD & " - " & strMessage
End Sub