natetron66 Posted August 4, 2009 Share Posted August 4, 2009 Hi everyone, I have a login script currently running that I created with autoit. I want to modify it to do another task as well, which is update the "Description" field of the computer object in AD when a user logs onto a machine. The reason being we have 1000 computers in a certain OU and theres only around 300 supposed to be there, as the other 700 are tombstoned pcs. I want to fill in the description field in AD, so after a week or two of users running this script I can delete the computer objects that do not have a description, hence cleaning up Active Directory. I want to use the user name of the person logging in to be the decription field. I currently already grab that in my login script. It is defined as $UserName. Please use this in any examples. I'm a total newb when it comes to scripting with AD. Thanks All! I appreciate it! Nate Link to comment Share on other sites More sharing options...
natetron66 Posted August 4, 2009 Author Share Posted August 4, 2009 Anyone??? Link to comment Share on other sites More sharing options...
Developers Jos Posted August 4, 2009 Developers Share Posted August 4, 2009 (edited) Does the user have the proper rights to write to the AD?Doesn't the Computer object contain a proper date for a user last changing the password while using this Computer you could retrieve from the AD?In VBS: lngDate = objRecordSet.Fields("pwdLastSet") Set objDate = lngDate dtmPwdLastSet = Integer8Date(objDate, lngBias)Link to vbsJos Edited August 4, 2009 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
99ojo Posted August 5, 2009 Share Posted August 5, 2009 (edited) Does the user have the proper rights to write to the AD?Doesn't the Computer object contain a proper date for a user last changing the password while using this Computer you could retrieve from the AD?In VBS: lngDate = objRecordSet.Fields("pwdLastSet") Set objDate = lngDate dtmPwdLastSet = Integer8Date(objDate, lngBias)Link to vbsJosHi,just do a:Your Computers are in OU MyOU in root of mydomain.namespace.local. You want to enumerate all computers of this ou, which are at least 4 weeks inactive:dsquery computer "OU=MyOU,dc=mydomain, dc=namespace, dc=local" -inactive 4 -limit 1000You shouldn't delete the computer accounts straight away. 1st i would set them disabled, and after a while i would delete them. You can make a combination of dsquery and dsmod:dsquery computer "ou=MyOU,dc=mydomain, dc=namespace, dc=local" -inactive 4 -limit 1000 | dsmod computer -disabled yes;-))Stefan Edited August 5, 2009 by 99ojo Link to comment Share on other sites More sharing options...
water Posted August 6, 2009 Share Posted August 6, 2009 (edited) To find out when the last logon of a computer to the domain happend just query the lastLogon attribute. You can use the adfunctions UDF which can be found here. You have to convert the returned value to readable format using this script. Edited August 6, 2009 by water 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