Skip navigation

JSI Tip 4675. How do I automate Ntdsutil using a batch file?


Ntdsutil.exe is a menu driven utility designed so that enterprise and domain administrators can manage and repair Active Directory.

Ntdsutil, from the Windows 2000 Support Tools, also has command line capability.

To script Ntdsutil, type the commands, separated by spaces. Multiple string parameters should be enclosed in double-quotes (").

To determine the roles of a given server:

ntdsutil roles "select operation target" "connections" "connect to server <ServerName> " quit "list roles for connected server" quit quit quit
Thankfully, you can abbreviate the commands:
ntdsutil r "sel o t" c "co t s <ServerName> " q "l r f c s" q q q
When I use:
ntdsutil r "sel o t" c "co t s JSI001 " q "l r f c s" q q q

it returns:

ntdsutil: r
fsmo maintenance: sel o t
select operation target: c
server connections: co t s JSI001
Binding to JSI001 ...
Connected to JSI001 using credentials of locally logged on user
server connections: q
select operation target: l r f c s
Server "JSI001" knows about 5 roles
Schema - CN=NTDS Settings,CN=JSI001,CN=Servers,CN=Default-First-Site-Name,CN=Sites,CN=Configuration,DC=JSIINC,DC=COM
Domain - CN=NTDS Settings,CN=JSI001,CN=Servers,CN=Default-First-Site-Name,CN=Sites,CN=Configuration,DC=JSIINC,DC=COM
PDC - CN=NTDS Settings,CN=JSI001,CN=Servers,CN=Default-First-Site-Name,CN=Sites,CN=Configuration,DC=JSIINC,DC=COM
RID - CN=NTDS Settings,CN=JSI001,CN=Servers,CN=Default-First-Site-Name,CN=Sites,CN=Configuration,DC=JSIINC,DC=COM
Infrastructure - CN=NTDS Settings,CN=JSI001,CN=Servers,CN=Default-First-Site-Name,CN=Sites,CN=Configuration,DC=JSIINC,DC=COM
select operation target: q
fsmo maintenance: q
ntdsutil: q
Disconnecting from JSI001 ...
See tip 3509 » Another way to locate a FSMO role holder.




Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish