Jump to content

Defragging multiples over a domain


Rapture

Recommended Posts

Hey guys,

 

I'm in need of some help. I need to get Defraggler running on multiple machines at certain times using a batch file. I've got defraggler accessible on a network share (easier to upgrade) and I need to run a batch that runs df.exe after hours.

 

What I want to do is create a few batch files that will run all the batch files within a folder (that folder would contain the info for the individual machines needed to be run at that time). I can just schedule the few main batch files on a domain server (ideally).

 

I'm not really sure how else to make this happen, or if it's even the best approach. I know I could make this all work with MS defrag utility, but I'd rather forgo that for defraggler.

 

Any help guys?

Link to comment
Share on other sites

Found a solution to my problem.

 

I was having issues doing this due to coming into a network environment that was very mature and well, foreign to me. Here's what I did for anyone looking...

 

First of all, PSExec made this job super simple. It's also required to use this particular solution.

 

What I wanted to do was keep a single copy of Defraggler on my network share (easier to upgrade), I also used the portable version for the INI file features. I also wanted to keep my files centralized on a server for myself and my colleagues to view and edit. These, along with psexec, is kept on our DC server (just out of choice, not out of requirement).

 

Once you have psexec on a server and defraggler on a network location, you'll need an account that can be used for all the machines you want this to run on (and schedule/ run the job). ***DOUBLE CHECK FILE PERMISSIONS AND RIGHTS*** -- This is required for your account to not only access the remote machines, but also to point back to the defraggler on the network drives.

 

Now it's time to create your folders. I kept all my work in a folder on my root of C: on my server, and it's here I tossed my text and batch files. If you have several hundred machines to do, you'll want to create a text file listing them. Get a list with the network names (you can alternatively do this by IP range) together. Now for your batch file, here's the meat of what you need...

 

cd c:\<Directory with pstools>
psexec @c:\<Directory>\<File containing computer names> -u <account> -p <passw> schtasks /create /sc <daily/weekly/etc> /d <day, if used> /st <time - military> /tn <task name> /tr "<net drive>"\<Directory with defraggler>\df.exe c:" /ru <domain account> /rp "<domain account passw>

 

The first set of the account is who created the account, you'll need admin privileges for the task to be run. The second account will be who the account runs under. This account will also require admin privileges as well as access to your network drive containing defraggler. I used the same account in both fields.

 

The first line on the batch file obviously redirects your path to the directory containing psexec. psexec will not run unless it's from the proper directory (go figure?). The second line (all one line) activates psexec and tells it to use the specified path to where your text file containing your computer names resides (again, you can instead run an IP range, google it to find out how to do that). It then uses the provided account to access those machines remotely. By nature, psexec only works within the c:\windows\system32\ file, again, research it if you need other tasks done, but for our purposes, scheduled tasks are here. It now will use the schtasks commands to apply the task to each machine one at a time. If you have issues with your path of defraggler, keep in mind the quotation marks as they do have a significance when pathing the program. It finally uses the last account to actually run the program, and this is very important since it must have both admin privileges on the machines, as well as network access.

 

For me, it was a requirement to offset when the machines begin their defrag (since we use a pure virtual environment), thus scheduling was required. Also, if you simply run defraggler through psexec to all the machines, it will only run it one by one and not move on until the defrag is complete on EACH machine! thus, it is advisable to keep your computer list small, even for scheduling defrag times (rule of thumb being approx. <50). This is easy to do as well if you have the same requirements of offsetting times, since you simply assign the small text documents to each batch file for it's specific time frame.

 

Finally, you can add whatever else you need to the batch files. I like to keep mine open and not force close once completed so I can see if the task failed to deploy. You can have this dump to a file if you wish, whatever!

 

Also, you'll want a batch to remove the tasks should you need to make a change. You won't want to go and remove a screwed up task from 50 machines or more individually!

 

As a side note, I also use this for ccleaner. You can create an exclusion/inclusion list to remove old task jobs if you want. I automate ccleaner through group policy however, set to run upon login. For redundancy, I have a task to run ccleaner should a machine not see use in some time.

 

Hope this helps anyone else out there looking for a network solution with a great product!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.