This will list Active Directory sites and subnets and display in a MsgBox. Formatting is ugly but that’s easy to change as required.
'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 = sSN & aSNInfo(0) & vbTab & vbTab
Else
sSN = sSN & aSNInfo(0) & ": " & _
Mid(Left(sResult.siteObject, Instr(sResult.siteObject, ",") - 1), 4) & _
vbTab & vbTab
End if
Next
wscript.echo sSN
To display your computer’s site:
Set adsSystemInfo = CreateObject("ADSystemInfo")
WScript.echo "Your site is: " & adsSystemInfo.SiteName
Set adsSystemInfo = Nothing
Popularity: 12% [?]
