Kaseya Community

Automated Exchange 'Maintenance' Scripts

  • Hi All,

    I have created a collection of scripts to automatically perform 'maintenance' of the Exchange Information store.

    One of the problems we run into is Exchange Information Store Corruption. This script (which I schedule in the middle of the night) will do the following:

    1. Dismount the Exchange Store

    2. Perform an ESEUTIL /P (to repair it)

    3. Perform an ISINTEG (to repair it some more Smile )

    4. Mounts the Exchange Store up again.

    Those who are eager for the individual scripts can find them below.. I wont post the 'Master Script' that runs each of these in order as I'm sure you guys can handle that... (if you cant you probably should stop reading right now.)

    Requires Variable(s): , , ,

    = Exchange Bin folder (usually CStick out tonguerogram filesexchsrvrbin)

    = Exchange Database Location (where the priv1.edb + pub1.edb files are)

    = This is the Exchange organisation name.. generally the Domain name?

    = this is the Domain Full Name in the format that Active Directory likes... for eg, Kaseya.com would be "DC=Kaseya,DC=com"... you dig?



    1. Dismount the Exchange Store

    Script Name: Private Mailbox Store Dismount
    Script Description: Dismounts the Private Mail Store and begins the Repair Scripts
    Required Variable(s): ,

    IF True
    THEN
    Delete File
    Parameter 1 : C:VSAFilesprivstoredismount.vbs
    OS Type : 0
    Execute Shell Command
    Parameter 1 : echo Set oDB = CreateObject("CDOEXM.MailboxStoreDB") >>>> C:VSAFilesprivstoredismount.vbs
    Parameter 2 : 1
    OS Type : 0
    Execute Shell Command
    Parameter 1 : echo strDB = "CN=Mailbox Store (%computername%),CN=First Storage Group,CN=InformationStore,CN=%computername%,CN=Servers,CN=First Administrative Group,CN=Administrative Groups,CN=,CN=Microsoft Exchange,CN=Services,CN=Configuration," >>>> C:VSAFilesprivstoredismount.vbs
    Parameter 2 : 1
    OS Type : 0
    Execute Shell Command
    Parameter 1 : echo oDB.DataSource.Open strDB >>>> C:VSAFilesprivstoredismount.vbs
    Parameter 2 : 1
    OS Type : 0
    Execute Shell Command
    Parameter 1 : echo oDB.Dismount() >>>> C:VSAFilesprivstoredismount.vbs
    Parameter 2 : 1
    OS Type : 0
    Execute Shell Command
    Parameter 1 : C:VSAFilesprivstoredismount.vbs
    Parameter 2 : 1
    OS Type : 0
    ELSE



    2. Perform an ESEUTIL /P (to repair it)

    Script Name: Private Mailbox Store Eseutil
    Script Description: Performs an ESEUTIL on the Private Store
    Required Variable(s): ,

    IF True
    THEN
    Execute Shell Command
    Parameter 1 : "esetuil.exe" /p /o"priv1.edb"
    Parameter 2 : 1
    OS Type : 0
    ELSE



    3. Perform an ISINTEG (to repair it some more Smile )

    Script Name: Private Mailbox Store Isinteg
    Script Description: Performs an ISINTEG.
    Required Variable(s):

    IF True
    THEN
    Delete File
    Parameter 1 : C:VSAFilesisinteg.txt
    OS Type : 0
    Write File
    Parameter 1 : C:VSAFilesisinteg.txt
    Parameter 2 : VSASharedFilesisinteg.txt
    OS Type : 0
    Execute Shell Command
    Parameter 1 : "isinteg.exe" -s %computername% -fix -test alltests <
    Parameter 2 : 1
    OS Type : 0
    ELSE



    4. Mounts the Exchange Store up again.

    Script Name: Private Mailbox Store Mount
    Script Description: Mounts the Private Mail Store and begins the Repair Scripts
    Required Variable(s): ,

    IF True
    THEN
    Delete File
    Parameter 1 : C:VSAFilesprivstoremount.vbs
    OS Type : 0
    Execute Shell Command
    Parameter 1 : echo Set oDB = CreateObject("CDOEXM.MailboxStoreDB") >>>> C:VSAFilesprivstoremount.vbs
    Parameter 2 : 1
    OS Type : 0
    Execute Shell Command
    Parameter 1 : echo strDB = "CN=Mailbox Store (%computername%),CN=First Storage Group,CN=InformationStore,CN=%computername%,CN=Servers,CN=First Administrative Group,CN=Administrative Groups,CN=,CN=Microsoft Exchange,CN=Services,CN=Configuration," >>>> C:VSAFilesprivstoremount.vbs
    Parameter 2 : 1
    OS Type : 0
    Execute Shell Command
    Parameter 1 : echo oDB.DataSource.Open strDB >>>> C:VSAFilesprivstoremount.vbs
    Parameter 2 : 1
    OS Type : 0
    Execute Shell Command
    Parameter 1 : echo oDB.Mount() >>>> C:VSAFilesprivstoremount.vbs
    Parameter 2 : 1
    OS Type : 0
    Execute Shell Command
    Parameter 1 : C:VSAFilesprivstoremount.vbs
    Parameter 2 : 1
    OS Type : 0
    ELSE

    NOTE: This script also requires a file called 'isinteg.txt' Now this file is VERY IMPORTANT and must be created exactly as follows...

    Create a text file with 3 lines on it. First line should be "1", second line should be "y" first line should be "".

    It should read as follows: (without the numbers obviously)

    1. 1

    2. Y

    3.


    Note: the 'blank' line is VERY important. Also note that you CANNOT 'upload' this to the Kaseya server as it seems tomodifyor 'parse'uploaded files and REMOVES the blank line which we know is critical. (Perhaps Kaseya should look into this) So basically you need to 'upload' it the old way, manually.

    FINAL NOTE: Minor modifications to this are required if you want it to work on the PUBLIC STORE.. please let me know if you want me to post the differences.

    ONE LAST THING: Reckon someone can make this sticky? It's fairly handy. And took me ages to write all this :-P


    (Edited ESEUTIL line to include /o)


    Legacy Forum Name: Automated Exchange 'Maintenance' Scripts,
    Legacy Posted By Username: nigel_bca
  • Nigal...



    but but.... if you are having message store corruption often enough that you have had to write a script to fix the problem, I submit to you that you have a much bigger problem than just corrupted stores.

    The message stores dont just become corrupted, something is causing the corruption. You should be looking for the cause of the corruption instead of just "fixing" the corruption. At some point, you will be into a recovery instead of just fixing the problem.

    The mostcommon cause of reoccuring message store corruption are visus scanners, both real time scanners and scheduled/manual virusscans, that are scanning the message stores. Your virus scanner should never, never scan the message stores, for any reason. You should exclude the message store directory and the log file directory from ALL virus scans.

    hc




    Legacy Forum Name: System Administration Scripts,
    Legacy Posted By Username: howardc
  • howardc wrote:
    Nigal...



    but but.... if you are having message store corruption often enough that you have had to write a script to fix the problem, I submit to you that you have a much bigger problem than just corrupted stores.

    The message stores dont just become corrupted, something is causing the corruption. You should be looking for the cause of the corruption instead of just "fixing" the corruption. At some point, you will be into a recovery instead of just fixing the problem.

    The mostcommon cause of reoccuring message store corruption are visus scanners, both real time scanners and scheduled/manual virusscans, that are scanning the message stores. Your virus scanner should never, never scan the message stores, for any reason. You should exclude the message store directory and the log file directory from ALL virus scans.

    hc




    Yes, I agree...

    However, this is particularly good to fix all existing corruption on MANY sites at once. Also makes it easy to repair corruption on new sites that we take-over.

    Also, it saves sitting there till 1:00am in the morning


    Legacy Forum Name: System Administration Scripts,
    Legacy Posted By Username: nigel_bca