Get computers AD site name

Started by Trippinout, February 10, 2017, 08:46:39 AM

Previous topic - Next topic

Trippinout

Anyone have a quick simple script to just get the current AD Site name from a computer.
Script will be run locally on the computer.

Thanks

td

"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

td

Here's a two liner that may (or may not) get you what you want.

adSys = CreateObject('ADSystemInfo')
strSiteName = adSys.GetDCSiteName('ServerNameHere')
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

Trippinout


td

A not very elegant  ADSI extender version.

Code (winbatch) Select
AddExtender("wwads44i.dll")
strServer = 'yourserver'
strServerPath = dsFindPath('LDAP://CN=Sites,CN=Configuration,DC=yoursub,DC=yourdomain', '(&(objectClass=server)(cn=%strServer%))')
strSite = ItemExtract(2, ItemExtract(3, strServerPath, ','), '=')
Pause(strServer:"'s Site", strSite)
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade