Login | |
|
 |
RE: List Domain Controllers - 4/10/2006 1:48:49 AM
|
|
 |
|
| |
ebgreen
Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
|
It is just a pet peeve of mine and has no functional effect at all, but there is no point to putting WScript.Quit at the end of the script. As I said it is a personal thing and I have always maintained that if the script does what you want then it is by definition written correctly.
_____________________________
"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
 |
RE: List Domain Controllers - 4/13/2006 12:55:33 AM
|
|
 |
|
| |
kirrilian
Posts: 628
Score: 3
Joined: 3/15/2005
From:
Status: offline
|
I thought I'd throw in my (modified scripting guy script as well!) domain controller role script as well '========================================================================== ' ' VBScript Source File -- Created with SAPIEN Technologies PrimalScript 4.0 ' ' NAME: getadroles.vbs ' ' AUTHOR: Kirrilian ' DATE : 11/3/2005 ' ' COMMENT: just run it, preferably with cscript :) ' code liberally hacked/borrowed from the script repository '========================================================================== 'put your domains in below domains = Array("domain1", "domain2", "domain3", "domain4") For Each domain In domains WScript.Echo "*********** Querying: " & domain & " *************" getdomaininfo domain WScript.echo Next Sub getdomaininfo(domain) 'needed for the gc queries On Error Resume Next Set objRootDSE = GetObject("LDAP://" & domain & "/rootDSE") 'ugly code follows... Set objSchema = GetObject _ ("LDAP://" & objRootDSE.Get("schemaNamingContext")) strSchemaMaster = objSchema.Get("fSMORoleOwner") Set objNtds = GetObject("LDAP://" & strSchemaMaster) Set objComputer = GetObject(objNtds.Parent) WScript.Echo "Forest-wide Schema Master FSMO: " & objComputer.Name Set objNtds = Nothing Set objComputer = Nothing Set objPartitions = GetObject("LDAP://CN=Partitions," & _ objRootDSE.Get("configurationNamingContext")) strDomainNamingMaster = objPartitions.Get("fSMORoleOwner") Set objNtds = GetObject("LDAP://" & strDomainNamingMaster) Set objComputer = GetObject(objNtds.Parent) WScript.Echo "Forest-wide Domain Naming Master FSMO: " & objComputer.Name Set objDomain = GetObject _ ("LDAP://" & objRootDSE.Get("defaultNamingContext")) strPdcEmulator = objDomain.Get("fSMORoleOwner") Set objNtds = GetObject("LDAP://" & strPdcEmulator) Set objComputer = GetObject(objNtds.Parent) WScript.Echo "Domain's PDC Emulator FSMO: " & objComputer.Name Set objRidManager = GetObject("LDAP://CN=RID Manager$,CN=System," & _ objRootDSE.Get("defaultNamingContext")) strRidMaster = objRidManager.Get("fSMORoleOwner") Set objNtds = GetObject("LDAP://" & strRidMaster) Set objComputer = GetObject(objNtds.Parent) WScript.Echo "Domain's RID Master FSMO: " & objComputer.Name Set objInfrastructure = GetObject("LDAP://CN=Infrastructure," & _ objRootDSE.Get("defaultNamingContext")) strInfrastructureMaster = objInfrastructure.Get("fSMORoleOwner") Set objNtds = GetObject("LDAP://" & strInfrastructureMaster) Set objComputer = GetObject(objNtds.Parent) WScript.Echo "Domain's Infrastructure Master FSMO: " & objComputer.Name 'check for global catalogs Const NTDSDSA_OPT_IS_GC = 1 Set objGC = GetObject("LDAP://OU=Domain Controllers," & _ objRootDSE.Get("defaultNamingContext")) For Each gc In objGC 'clean up the ldap response gc = Replace(gc.name, "CN=", "") Set objRootDSE = GetObject("LDAP://" & gc & "/rootDSE") strDsServiceDN = objRootDSE.Get("dsServiceName") Set objDsRoot = GetObject("LDAP://" & gc & "/" & strDsServiceDN) 'this doesnt always exist therefore we have to use on error resume next intOptions = objDsRoot.Get("options") 'check to see if the previous command failed with the err.number function If intOptions And NTDSDSA_OPT_IS_GC and err.Number = 0 Then WScript.Echo gc & " is a global catalog server." Else WScript.Echo gc & " isnt up or isnt a global catalog server." Err.Clear End If next End Sub 'getdomaininfo
_____________________________
Have you searched here ? VBScript Fundamentals My Site
|
|
| |
|
|
|
|
|