cmgrider Posted February 15, 2008 Share Posted February 15, 2008 I am writing a script to allow Desktop Technicians to Install Printers remotely via printui.dll... I found an excellent script already done in another section of Forums which does this locally on a PC. In attempting to tweak that script I want to add either of 2 options. 1. an input field where the technician can type the name of the Workstation. then the script will Query AD and return a dialog telling them if the PC name is valid or doesnt exist in the domain. Where upon they can verify spelling etc... 2. (the preferred method) Allow the tech to click a button which populates a drop down with all Workstaiton names in AD and allows them to select the one they want to push the printer too. This name is then passed to the script to install the printer. I need help either validating the PC name exists in AD or populating a list for the Tech to choose from. I am fairly certain someone has probably had a similar need in the past for finding PC's in the domain. I am just new enough at autoit that I havent been able to figure out the proper code. Any help is greatly appreciated. Thanks, Chris Link to comment Share on other sites More sharing options...
SpookMeister Posted February 15, 2008 Share Posted February 15, 2008 #include <array.au3> $PCs = _RecieveComputersLDAP(@LogonDomain) If IsArray($PCs) Then _ArrayDisplay($PCs) Else MsgBox(0, "Error", "Well that didn't work") EndIf Func _RecieveComputersLDAP($Domain) Local $ObjDomain = ObjGet("WinNT://" & $Domain) Local $pc_names="", $list For $Object In $ObjDomain If $Object.class = "Computer" Then $pc_names &= $Object.Name & "|" Next If StringLen($pc_names) > 1 Then $list = StringTrimRight($pc_names, 1) Return StringSplit($list, "|") Else SetError(1) EndIf EndFunc ;==>_RecieveComputersLDAP [u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote] Link to comment Share on other sites More sharing options...
cmgrider Posted March 5, 2008 Author Share Posted March 5, 2008 #include <array.au3> $PCs = _RecieveComputersLDAP(@LogonDomain) If IsArray($PCs) Then _ArrayDisplay($PCs) Else MsgBox(0, "Error", "Well that didn't work") EndIf Func _RecieveComputersLDAP($Domain) Local $ObjDomain = ObjGet("WinNT://" & $Domain) Local $pc_names="", $list For $Object In $ObjDomain If $Object.class = "Computer" Then $pc_names &= $Object.Name & "|" Next If StringLen($pc_names) > 1 Then $list = StringTrimRight($pc_names, 1) Return StringSplit($list, "|") Else SetError(1) EndIf EndFunc ;==>_RecieveComputersLDAP Thanks for the script, it works great for getting PC names from domain. One additional question. Any idea how to take the output and have it available via a drop down allowing the technician to select from the list? I am attempting to use a GUI to have the techs click find PC button which will then query AD and allow selection via a dropdown list. Then whichever PC they select I can pass it through to the portion of the script used to install printer on that particular PC. Thanks Again, Chris 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