WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: Orionbelt on February 17, 2015, 01:34:56 PM

Title: Get certain objects from AD
Post by: Orionbelt on February 17, 2015, 01:34:56 PM
Hi all,
   I am trying to get objects from AD. But i would like to get only computers which start as L,D,USD,USL,P.


;  Get the domain DN with a server-less ADSI path.
domain = dsGetProperty("LDAP://rootDSE"  , "defaultNamingContext")      ; DC=microsoft,DC=mill,DC=com
sPath = "LDAP://CN=Computers,":domain              ; LDAP://CN=Computers,DC=microsoft,DC=mill,DC=com
lValues = dsGetChldPath(sPath, "")                              ; ALL Objects from path sPath

i can loop valuse of IValues and extract single object. but how can i say that if computer starts with L OR D OR USD OR USL OR R than continue otherwise keep looping.
Title: Re: Get certain objects from AD
Post by: td on February 17, 2015, 02:09:39 PM
The dsFindPath function is your ADSi extender friend

Code (winbatch) Select
lComputers = dsFindPath(strYourContainerPath, "(&(objectCategory=Computer)(| (cn=l*)(cn=d*)(cn=usd*)(cn=usl*)(cn=r*)))")
Title: Re: Get certain objects from AD
Post by: Orionbelt on February 17, 2015, 02:55:35 PM
Perfect....thanks