Scripting Active Directory Commands
#1
Posted 18 August 2011 - 10:42 PM
I am new to scripting in AutoIt and am having some troubles. I am using JoeWare's adfind.exe and admod.exe AD tools to modify User/Computer object attributes.
Currently I open a command prompt where the .exe's are located and run the following command:
adfind.exe -b -default -rb "ou=Printers,ou=Anaconda,ou=OPD,ou=DOA" -f "&(objectCategory=computer)(!doaITSDBillingClient=EXE-OPD-610805-OPD_20520)" -dsq | admod.exe "doaITSDBillingClient::EXE-OPD-610805-OPD_20520" -unsafe
Basically it searches a defined OU for computer objects and pipes the results into the modification tool. I have about 50 similar commands to run on different OUs and object types so I would like to get them all into one script. Currently I have attempted using the following code in an AutoIt script, but it is not working:
RunWait(@ComSpec & '"C:\ADTools\adfind.exe -b -default -rb "ou=Printers,ou=Anaconda,ou=OPD,ou=DOA" -f "&(objectCategory=computer)(!doaITSDBillingClient=EXE-OPD-610805-OPD_20520)" -dsq | admod.exe "doaITSDBillingClient::EXE-OPD-610805-OPD_20520" -unsafe"')
Any help you can provide me as a n00b is greatly appreciated.
Cheers
#2
Posted 18 August 2011 - 11:06 PM
Hello All,
I am new to scripting in AutoIt and am having some troubles. I am using JoeWare's adfind.exe and admod.exe AD tools to modify User/Computer object attributes.
Currently I open a command prompt where the .exe's are located and run the following command:
adfind.exe -b -default -rb "ou=Printers,ou=Anaconda,ou=OPD,ou=DOA" -f "&(objectCategory=computer)(!doaITSDBillingClient=EXE-OPD-610805-OPD_20520)" -dsq | admod.exe "doaITSDBillingClient::EXE-OPD-610805-OPD_20520" -unsafe
Basically it searches a defined OU for computer objects and pipes the results into the modification tool. I have about 50 similar commands to run on different OUs and object types so I would like to get them all into one script. Currently I have attempted using the following code in an AutoIt script, but it is not working:
RunWait(@ComSpec & '"C:\ADTools\adfind.exe -b -default -rb "ou=Printers,ou=Anaconda,ou=OPD,ou=DOA" -f "&(objectCategory=computer)(!doaITSDBillingClient=EXE-OPD-610805-OPD_20520)" -dsq | admod.exe "doaITSDBillingClient::EXE-OPD-610805-OPD_20520" -unsafe"')
Any help you can provide me as a n00b is greatly appreciated.
Cheers
I just thought I would add that I have each of the 50 or so pieces of code in separate text files right now...don't know if there is an easier way to go about the whole process but am open to any and all suggestions.
#3
Posted 19 August 2011 - 04:32 AM
Functions _AD_GetObjectsInOU and _AD_ModifyAttribute should do what you need.
UDFs:
Active Directory (2012-10-12 - Version 1.3.0.0 released) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2012-10-07 - Version 0.9.0.0 released) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2013-01-21 - Version 0.3.1.1 released) - Download - General Help & Support - Example Scripts
WordEX (2012-12-29 - Version 1.3 released) - Download
ExcelEX (2013-05-11 - Alpha 4 released) - Download
#4
Posted 16 February 2012 - 12:33 AM
#5
Posted 16 February 2012 - 07:28 AM
I assume you pass the SamAccountName to the function (e.g. @Username for a user account or @ComputerName for the computer account).I can get the _AD_ModifyAttribute to modify a users description but not a computers description.
The SamAccountName of a computer has a Dollar sign appended.
So you have to pass: @ComputerName & "$"
UDFs:
Active Directory (2012-10-12 - Version 1.3.0.0 released) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2012-10-07 - Version 0.9.0.0 released) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2013-01-21 - Version 0.3.1.1 released) - Download - General Help & Support - Example Scripts
WordEX (2012-12-29 - Version 1.3 released) - Download
ExcelEX (2013-05-11 - Alpha 4 released) - Download
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users




