Lists subnets in all Active Directory sites. STDOUT is formatted as a comma-separated values file to accommodate redirecting to a file format compatible with Excel.
Set objRootDSE = GetObject("LDAP://RootDSE")strConfigurationNC = objRootDSE.Get("configurationNamingContext")strSubnetsContainer = "LDAP://cn=Subnets,cn=Sites," & strConfigurationNCSet objSubnetsContainer = GetObject(strSubnetsContainer)objSubnetsContainer.Filter = Array("subnet")Set objHash = CreateObject("Scripting.Dictionary")For Each objSubnet In objSubnetsContainerobjSubnet.GetInfoEx Array("siteObject"), 0strSiteObjectDN = objSubnet.Get("siteObject")strSiteObjectName = Split(Split(strSiteObjectDN, ",")(0), "=")(1)If objHash.Exists(strSiteObjectName) ThenobjHash(strSiteObjectName) = objHash(strSiteObjectName) & "," & _Split(objSubnet.Name, "=")(1)ElseobjHash.Add strSiteObjectName, Split(objSubnet.Name, "=")(1)End IfNextFor Each strKey In objHash.KeysWScript.Echo strKey & "," & objHash(strKey)Next
This is a VB Script, this can be used by saving the file in .vbs file