Command line tool to return "my" AD site

  • Thread starter Thread starter Charles Kerekes
  • Start date Start date
C

Charles Kerekes

Hey everyone,

Is there a command line tool that returns the AD site
name for the machine it was executed on? Windows 2000 and
later do this under the covers to locate a DC via API
calls. I'm looking for the same process for the command
line.

I am familiar with the dsquery command that comes with
2003, and I am able to use it to get this information in
four steps. For example:

1) dsquery.exe subnet -name 192.82.235.*

2) Parse the result down to the subnet name only.
Example: 192.82.235.0/24

3) dsquery.exe *
CN=subnets,CN=sites,CN=configuration,DC=MyDomain,DC=com
-scope subtree -filter (cn=192.82.235.0/24)
-attr siteObject

4) Parse the result down to the site name only.

Before writing my own script to bring these commands
together, I thought I would check if anyone has already
done this.

Charlie
 
Back
Top