Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

VB Script for running Exchange Integrity Checks

Posted on 2010-08-19
18
Medium Priority
?
572 Views
Last Modified: 2012-05-10
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
Comment
Question by:agentkolb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 6
  • 2
  • +1
18 Comments
 
LVL 31

Expert Comment

by:MegaNuk3
ID: 33479231
/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
 

Author Comment

by:agentkolb
ID: 33479246
MegaNuk3,

You are correct. I meant /G Thanks!
0
 
LVL 31

Expert Comment

by:MegaNuk3
ID: 33479261
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
Does Powershell have you tied up in knots?

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

 
LVL 31

Expert Comment

by:MegaNuk3
ID: 33479280
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
 
LVL 12

Expert Comment

by:Rant32
ID: 33479682
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
 
LVL 31

Expert Comment

by:MegaNuk3
ID: 33479743
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
 
LVL 12

Expert Comment

by:Rant32
ID: 33480267
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
 
LVL 31

Expert Comment

by:MegaNuk3
ID: 33485233
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
 
LVL 12

Expert Comment

by:Rant32
ID: 33485939
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
 
LVL 31

Expert Comment

by:MegaNuk3
ID: 33488339
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
 
LVL 12

Expert Comment

by:Rant32
ID: 33522007
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
 
LVL 12

Accepted Solution

by:
Rant32 earned 2000 total points
ID: 33526459
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
 
LVL 12

Expert Comment

by:Rant32
ID: 33526518
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
 

Author Comment

by:agentkolb
ID: 33576922
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
 
LVL 12

Expert Comment

by:Rant32
ID: 34075993
This is not an objection, but I'd still like to know how it went...
0
 
LVL 71

Expert Comment

by:Qlemo
ID: 34109766
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are times when we need to generate a report on the inbox rules, where users have set up forwarding externally in their mailbox. In this article, I will be sharing a script I wrote to generate the report in CSV format.
If something goes wrong with Exchange, your IT resources are in trouble.All Exchange server migration processes are not designed to be identical and though migrating email from on-premises Exchange mailbox to Cloud’s Office 365 is relatively simple…
In this video we show how to create an email address policy in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.:  First we need to log into the Exchange Admin Center. Navigate to the Mail Flow…
The basic steps you have just learned will be implemented in this video. The basic steps are shown to configure an Exchange DAG in a live working Exchange Server Environment and manage the same (Exchange Server 2010 Software is used in a Windows Ser…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question