WinBatch® Technical Support Forum

Archived Boards => Network Extenders => Topic started by: Trippinout on February 10, 2017, 08:46:39 AM

Title: Get computers AD site name
Post by: Trippinout on February 10, 2017, 08:46:39 AM
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
Title: Re: Get computers AD site name
Post by: td on February 10, 2017, 11:24:35 AM
This longish script illustrates how to obtain the site name for the current domain along with a bunch of other stuff.

http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WIL~Extenders/ADSI/Samples~from~Users+Useful~ADSI~Site~server~functions.txt  (http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WIL~Extenders/ADSI/Samples~from~Users+Useful~ADSI~Site~server~functions.txt)
Title: Re: Get computers AD site name
Post by: td on February 10, 2017, 11:54:55 AM
Here's a two liner that may (or may not) get you what you want.

adSys = CreateObject('ADSystemInfo')
strSiteName = adSys.GetDCSiteName('ServerNameHere')
Title: Re: Get computers AD site name
Post by: Trippinout on February 10, 2017, 12:14:22 PM
Perfect. Thanks..
Title: Re: Get computers AD site name
Post by: td on February 10, 2017, 02:09:53 PM
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)