So I'm doing a report about our AD infrustructure and some specific servers. The report needs to show which subnets are being covered by a specific site. Easy eh? Just open up ADSS and go to the site you need the information about and simply copy the subnets.
Hah! Why would Microsoft make it that easy? Well, they wouldn't. Sorry, no copy, no pastey.
So here is a script that will list all the subnets for a site in CIDR format. I like it. You will too.
Just enter the name of the site as you see it in ADSS as an argument. No need to enter the distinguished name or any other kind of mumbo jumbo.
Oh, make sure you run this with cscript, not wscript.
varSiteName = lcase(WScript.Arguments(0)) 'list the regular name that you see in ADSS, not the DN
Set objRootDSE = GetObject("LDAP://RootDSE")
strDomainCNC = objRootDSE.get("configurationNamingContext")'working with the configuration container
set objSites = getObject("LDAP://CN=sites," & strDomainCNC)'grabbing all sites
For Each i In objSites'for each site
If lcase(i.cn) = varSiteName Then 'if the name is the same as the argument
For Each x In i.siteObjectBL 'then list all the subnets (siteObjectBL is a list of the DN of all the subnets for that site.
aryx = Split(x,",CN=") 'clean up
WScript.Echo Mid(aryx(0),4) 'more cleanup
Next
End If
Next