Scripting NTDSUTIL

NTDSUtil.exe is an Active Directory Utility which is used for a number of administrative tasks. In my blog I have talked about a number of administrative tasks such as defraging AD, removing AD objects and so on. Using scripts is some times easier and for that I have included a reference to a TechNet article which although short shows how easy scripting for this tool is if you know the commands you want to run.

How to automate Ntdsutil.exe using a script

Here are some examples from the article:

In the long form the following script returns a list roles held by the server:

c:\ntdsutil roles “select operation target” “connections” “connect to server servername” quit “list roles for connected server” quit quit quit

In the short form, the following script performs the same action as above however it uses abbreviated commands

c:\ntdsutil r “sel o t” c “co t s servername” q “l r f c s” q q q

Here is another script to defrag an RODC database:

c:\ntdsutil “activate instance ntds” files info “compact to c:\temp”

For more information about what to do with a compacted AD database please see the following article:

RODC: How to Defrag or Compact the Active Directory Database

Jeff Loucks
Available Technology
Available Technology
  Subscribe in a reader 

Leave a Reply

Your email address will not be published. Required fields are marked *