[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 574
  • Last Modified:

VB Script for running Exchange Integrity Checks

I am looking to create a VB Script or Batch file that will dismount my exchange stores, run eseutil and defrag them, then run an integrity check w/ the P parameter, then run ISINTEG with the fix parameter, then remount the stores. I am hoping to have them not name specific so I can run them on a few different domains.
0
agentkolb
Asked:
agentkolb
  • 7
  • 6
  • 2
  • +1
1 Solution
 
MegaNuk3Commented:
/P is not integrity check it is hard repair, which you should never run unless your database is failing to mount or is corrupt

/G is integrity
0
 
agentkolbAuthor Commented:
MegaNuk3,

You are correct. I meant /G Thanks!
0
 
MegaNuk3Commented:
A simple batch file would be:
net stop msexchangeis
eseutil /g <EDB name> >>c:\eseutil.log
isinteg -s servername -fix -test alltests  >>isinteg.log
net start msexchangeis

as long as the databases are set to mount on startup then the databases should mount.
0
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
MegaNuk3Commented:
oops I forgot the eseutil /d in there... best to run that before the isinteg.

I don't think there is any point in running the /g as the /d is going to create a new database anyway.
0
 
Rant32Commented:
I guess GP is looking for a way to find those EDB names automatically. It's in AD somewhere :)
I have a huge pile of Exchange/AD VB scripting at work, but it'll have to wait a little.

Also, I would like to unroot the belief that defragmenting with eseutil is inherently Good.
Defragmenting the database files is really only recommended if you expect to gain a lot of free disk space from it, or if you absolutely want to shrink the files.

It's better to have the files physically contiguous (using disk defragmenter or the likes) and leave the database files with enough free space to prevent growth and new fragmentation. The files will probably grow again to the same size anyway, unless your database usage has changed.

Just to be verbose, information from performance counters is very useful: for example, how much free space is available in the database and the total size. If you gain 600 MB on a 11 GB database, or less than 20% for example, I'd skip the defrag. This also allows you to estimate the amount of time required for all of this.
0
 
MegaNuk3Commented:
Have a look for the 1221 event, if you are not going to gain large amounts of whitespace back then it is not worth doing the defrag.

It is normally easier and quicker to move all the mailboxes to a new DB.
0
 
Rant32Commented:
But moving mailboxes will lose single instance storage on previous Exchange versions, and may not solve physical fragmentation.
Depending on the SIS ratio, your database could grow mildly (which is the opposite effect of defragmenting) or it could blow up (which is not good if you're already pushing the size limits of Standard Edition).

Sorry, I don't agree. It may be faster, but it doesn't accomplish much in terms of reducing size.
0
 
MegaNuk3Commented:
When you move mailboxes they lose their items in deleted item retention so you will get a lot of space back that way.

There are advantages to both methods. Moving mailboxes does not require hours of downtime for the DB and all the mailboxes on it though
0
 
Rant32Commented:
Nuke, now you've actually lost me. Why would you configure deleted item retention, only to throw it away during maintenance?

Saving space on deleted items is useless, because it's a sliding window. The space gain is bogus after 30 days, or whatever the deleted item retention time is, and you're left with all duplicated items.

ESE will perform best without tricks like these. If it's not worth the downtime, then it's not worth the maintenance.
0
 
MegaNuk3Commented:
deleted item retention is good if you have users who accidentally delete things and want it back a couple days later then you can just undelete it....

If you are trying to shrink the database as much of possible then getting rid of all the deleted item retention is good...
0
 
Rant32Commented:
I'm almost finished with the script that I promised. I just need to add a disk space check and to test portability, I need to run it against another Exchange test server I have.

Just a little while...
0
 
Rant32Commented:
Alright, here it is. A few things:

- It doesn't run isinteg -fix. First of all, it's a pain to make it unattended, second, they did make it so deliberately. Fixing databases is not a routine job.
- The integrity check runs first. If that succeeds, the store is defragmented.
- There is a line "DoNothing = True". You must change it to "DoNothing = False" to actually perform the intrusive tasks like dismounting the store.
- To defrag, you need at least the amount of free space equal to the database size (edb+stm). The TEMPDEFRAG files end up in the working directory where you run the script from, so that space counts (e.g. don't run it from CD :)
- Databases that are not mounted to begin with will not be mounted again.
- Output is logged to console, so if you want a log file then redirect > to file.

Otherwise, all paths and databases are collected so it should run against any Exchange 2003 server regardless of Storage Groups and the amount of stores.

Check the output first with DoNothing=True to see if it does what you expect.
ExchangeStores.vbs
0
 
Rant32Commented:
Oh, I forgot to mention: because of the way ESEUTIL writes its output to StdOut (console), you may not see any progress or output while the Integrity/Defrag command is running. You will have the output when it's finished. So no progress, sorry.
0
 
agentkolbAuthor Commented:
Hey Rant, thanks so much for the script. Give me a few to test to ensure it does like I asked and I appreciate all the hard work!
0
 
Rant32Commented:
This is not an objection, but I'd still like to know how it went...
0
 
QlemoC++ DeveloperCommented:
This question has been classified as abandoned and is being closed as part of the Cleanup Program.  See my comment at the end of the question for more details.
0

Featured Post

Microsoft Certification Exam 74-409

VeeamĀ® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

  • 7
  • 6
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now