SlowCoder74 Posted May 22, 2012 Share Posted May 22, 2012 (edited) I need to run a presumably simple search for computers in AD.From a search, I found this thread:and downloaded adfunctions.au3.Here is my code:#include "H:AutoIT Projects_Routinesadfunctions.au3" Global $aComputers $sOU = $strDNSDomain $retVal = _ADGetObjectsInOU($aComputers,$sOU,"(objectclass=computer,name=nfdv*)",2,"name") msgbox(0,"",$retVal) _ArrayDisplay($aComputers)Based on notes in the adfunctions routine, I added "name=nfdv*" to retrieve all PCs starting with "nfdv", which should yield about 50. It took just a few seconds, but the $retVal = 0, which is (from what I can tell) the return code for no objects found.I don't know if it helps at all, but the computernames I need are nested 2 layers deep from the top domain. In other words: MyDomain top > OU 1 > OU 2 computername1 computername2 ... etc. ...Also, if I need to get the object description, is the proper fieldname to add to $datatoretrieve called "description"? Edited May 22, 2012 by SlowCoder74 Link to comment Share on other sites More sharing options...
water Posted May 22, 2012 Share Posted May 22, 2012 Download my AD UDF (it's the successor of the adfunctions UDF). Then your script should look like this: #include "H:\AutoIT Projects\_Routines\AD.au3" _AD_Open() Global $aComputers = _ADGetObjectsInOU("","(&(objectclass=computer)(name=nfdv*))",2,"name") If @error then MsgBox(16, "Error", "Error returned by _AD_GetObjectsInOU. @error = " & @error & ", @extended = " & @extended) _ArrayDisplay($aComputers) _AD_Close() My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
SlowCoder74 Posted May 22, 2012 Author Share Posted May 22, 2012 (edited) Excellent! That works.Now, I'm trying to obtain the descriptions of the computers. I change the field list to "name,description", The output adds another field, but the 2nd field is blank. When I look in AD, the descriptions are full of data. Am I missing something?Even when I just put in "description", the data is blank.Scratch that. I played with the code a bit more, and it's working now. Thank you! Edited May 22, 2012 by SlowCoder74 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now