Initiate an online defrag (VBScript)

This code can be found in Chapter 17 of Active Directory Cookbook, 2nd edition

Purchase XP Cookbook or Networking Recipes for only $25 plus shipping! While supplies last.

Find out how to download all of the VBScript code from this site.

' This VBScript code kicks off an online defrag to run for up to 180 seconds

' ---------------------------------------------------------------
' From the book "Active Directory Cookbook" by Robbie Allen
' ISBN: 0-596-00466-4
' ---------------------------------------------------------------

' ------ SCRIPT CONFIGURATION ------
strDC = "<DomainControllerName>"  ' e.g. dc01
' ------ END CONFIGURATION ---------

set objRootDSE = GetObject("LDAP://" & strDC & "/RootDSE")
objRootDSE.Put "DoOnlineDefrag", 180
objRootDSE.SetInfo
WScript.Echo "Successfully initiated an online defrag"

This code has been viewed 2180 times.

New from the creators of TechTasks.com: StatSheet.com