-
Notifications
You must be signed in to change notification settings - Fork 1
/
ADSites.vbs
29 lines (21 loc) · 907 Bytes
/
ADSites.vbs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
On Error Resume Next
Set objSiteFSO = CreateObject("Scripting.FileSystemObject")
set ObjSiteFile = objSiteFSO.createTextFile("c:\ADscripts\ADLogs\ADSites.txt", true)
Set objRootDSE = GetObject("LDAP://RootDSE")
strConfigurationNC = objRootDSE.Get("configurationNamingContext")
strSitesContainer = "LDAP://cn=Sites," & strConfigurationNC
Set objSitesContainer = GetObject(strSitesContainer)
objSitesContainer.Filter = Array("site")
For Each objSite In objSitesContainer
objSiteFile.WriteLine objSite.CN
strSiteName = objSite.Name
strServerPath = "LDAP://cn=Servers," & strSiteName & ",cn=Sites," & _
strConfigurationNC
Set colServers = GetObject(strServerPath)
For Each objServer In colServers
objSiteFile.WriteLine vbTab & objServer.CN
Next
objSiteFile.WriteLine vbCRLF
Next
WScript.Echo "Script... Done....."
objSiteFile.Close