jgq85 Posted October 21, 2011 Share Posted October 21, 2011 I'm trying to get my script to open Active Directory (on my computer) and then search for an employee's name. However, it seems as though the "Active Directory Users and Computers" window doesn't really respond to any thing once it's open. ; Open the RUN command Send("#r") Sleep(1200) ; Opens Active Directory Send("dsa.msc /server=domainserver1.domain.com") Send("{ENTER}") Sleep(3000) At this point, Active Directory Users and Computers is open and shown to connect to the specified server, but anything beyond this point does not work in the window. It works fine if I switch out AD with Notepad or Word. If I do a Send("!a") it doesn't even indicate Alt is pressed in the window, let alone activate "Actions" menu (alt+a). I tried appending: WinSetState("Active Directory", "", @SW_MAXIMIZE) ...but even that won't affect the window. Is there a better way to even do this? I'm basically trying to bring up AD and get to the Find box, and then type/paste in an employee's name that I've got copied to the clipboard. Link to comment Share on other sites More sharing options...
water Posted October 21, 2011 Share Posted October 21, 2011 You could use my Active Directory UDF. Depending on the information you enter (name, samaccountname ..) and the information you want to retrieve different functions are available. A good choice might be _AD_GetObjectsInOU. 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...
jgq85 Posted October 22, 2011 Author Share Posted October 22, 2011 Ok I'll check it out. I did search earlier for a way to just Disable an AD account, but didn't find anything. Ultimately, that's what I'm trying to do. But I kind of do want the AD window to open with the employee's name in the search box, so that I can go into properties manually and add details to their Description, or change their Organizational Manager, etc... Link to comment Share on other sites More sharing options...
jgq85 Posted October 22, 2011 Author Share Posted October 22, 2011 (edited) Maybe have AutoIt launch PowerShell and type the command to disable the EmployeeName's account? Then could Autoit wait until I close the Powershell window to resume to the program? Edited October 22, 2011 by jgq85 Link to comment Share on other sites More sharing options...
jgq85 Posted October 22, 2011 Author Share Posted October 22, 2011 Something like this? $EmployeeNameValue = GUICtrlRead($EmployeeName) Run(@WindowsDir & "\System32\WindowsPowerShell\v1.0" & "\Powershell.exe", @WindowsDir, @SW_MAXIMIZE) Sleep(1400) Send("Type command here to disable employeenamevalue") Link to comment Share on other sites More sharing options...
water Posted October 22, 2011 Share Posted October 22, 2011 Ok I'll check it out. I did search earlier for a way to just Disable an AD account, but didn't find anything. Ultimately, that's what I'm trying to do. But I kind of do want the AD window to open with the employee's name in the search box, so that I can go into properties manually and add details to their Description, or change their Organizational Manager, etc... To disable an account (where you already know the SamAccountname) the script would look like: #include <AD.au3> Global $sSAM = "xxx" _AD_Open() _AD_DisableObject($sSAM) _AD_Close() Some error checking after each function call is needed. To change the description you call _AD_ModifyAttribute($sSAM, "Description", "New Description") 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...
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