If you ever need to look up which subnet is associated with which active directory site then just paste the below into vbs and pipe its output to a text file.
‘Get list of AD subnets
Set oRootDSE = GetObject(“LDAP://RootDSE”)
sConfigurationNC = oRootDSE.Get(“configurationNamingContext”)
Set oRootDSE = Nothing
sSubnetsContainer = “LDAP://cn=Subnets,cn=Sites” & “,” & sConfigurationNC
Set oSubnetsContainer = GetObject(sSubnetsContainer)
For Each sResult In oSubnetsContainer
aSNInfo = Split(sResult.cn, “/”)
If Instr(sResult.siteObject, “,”) = 0 Then
sSN = aSNInfo(0)
sSN = aSNInfo(0) & “,” & _
Mid(Left(sResult.siteObject, Instr(sResult.siteObject, “,”) – 1), 4)
If you name the script listsites.vbs and want to output to a file call sitelist.csv and the script sites in a folder called “support” you can just run the following command line.
cscript c:supportlistsites.vbs > c:supportsitelist.csv
One thought on “List Active Directory sites and their associated subnets”
It works very well.
Thanks for your post.
David from France.