 |
How do I find the name of my Primary Domain Controller (PDC)?
|
 |
|
How do I find the name of my Primary Domain Controller, and how do I find out which domain controller I logged into? The answer is in VBScript.
Copy the following code into notepad and save it as a file called "findDC.vbs"
==Begin code==
REM if the clients are W2k or above, the ADSystemInfo object has SiteName and
REM GetAnyDCName. If the offices are each in a defined site, then SiteName would
REM be good. I can't find documentation on GetAnyDCName, but I think it will be
REM the DC that responds first. It will be the DNS name in the form similar to
REM MyServer.MyDomain.com.
Set objSysInfo = CreateObject("ADSystemInfo")
Wscript.Echo "ADSystemInfo.SiteName.:" & objSysInfo.SiteName
Wscript.Echo "ADSystemInfo.SiteName.GetAnyDCName:" & objSysInfo.GetAnyDCName
REM If the client is NT or above, you can retrieve the environment variable
REM %LOGONSERVER%, in the form MyServer:
Set objShell = CreateObject("Wscript.Shell")
Wscript.Echo "Wscript.Shell.Environment.Process.LogonServer:" & objShell.Environment("Process").Item("LogonServer" )
REM Finally, on any client (Windows 95 or above, with DSClient), the RootDSE
REM object can retrieve ServerName:
Set objRootDSE = GetObject("LDAP://RootDSE")
Wscript.Echo "LDAP://RootDSE . ServerName:" & objRootDSE.ServerName
REM The last will be similar to
REM "cn=MyServer,cn=servers,cn=MySite,cn=sites,cn=conf iguration,dc=MyDomain,dc=c
REM om", so you have to parse it for the DC name.
REM There is also WinNTSystemInfo.PDC, but it seems to only be available on W2k
REM and above:
Set objNTInfo = CreateObject("WinNTSystemInfo")
Wscript.Echo "WinNTSystemInfo.PDC:" & objNTInfo.PDC
==End code==
Results
Save the code and open a command prompt in the directory where you saved the file. If you saved it in C:My Documents, do Start Menu -- run -- cmd. Then cd "My Documents"
At the command prompt, type
cscript findDC.vbs
The output will look like this
ADSystemInfo.SiteName.:YourSite
ADSystemInfo.SiteName.GetAnyDCName:YourBDC.tree.domain
Wscript.Shell.Environment.Process.LogonServer:YourBDC
LDAP://RootDSE . ServerName:CN=YourBDC,CN=Servers,CN=YourSite,CN=Sites,
nfiguration,DC=ds,DC=uhc,DC=com
WinNTSystemInfo.PDC:YourPDC
Bumped from the original popular Group29 Forums article: How do find the name of my Primary Domain Controller (PDC)?
|
|
|
|
Posted on Friday, June 20, 2008 @ 07:29:02 UTC by BB
|
|
|
|
"How do I find the name of my Primary Domain Controller (PDC)?" | Login/Create an Account | 0 comments |
| The comments are owned by the poster. We aren't responsible for their content. |
|
|
|
|
|
No Comments Allowed for Anonymous, please register |
|
|
|
|
|