1

I am trying to write a batch script to find the domain controller hostname.

Based from the following article

nslookup

set type=all

_ldap._tcp.dc._msdcs.domain.name

What I would like to try and get working is at the start it prompts you for the domain name and then you enter it and it calls later on and replaces domain.name in the third line.

The idea is that I can hop onto one of my clients machines run the script and find exactly where the DC is for things like password resets

So far I have the following but it crashes instantly after entering the domain name

@echo off
set /p domain="Enter domain name: "

nslookup
set type=all
_ldap._tcp.dc._msdcs.%domain%

pause
Compo
  • 36,585
  • 5
  • 27
  • 39

1 Answers1

0

To locate the domain server that the client is currently using:

nslookup -type=any %USERDNSDOMAIN%

I am glad your question was not how to find any and/or all domain servers on the network.

lit
  • 14,456
  • 10
  • 65
  • 119