Elephant007 Posted July 11, 2012 Share Posted July 11, 2012 (edited) I'm trying to work on a script for work and this is what I need it to do Find users in a "ready to delete" ou, dump them in a text file Have autoit read the text file per user and search three locations \\Staff1\StaffStrorage\users.name \\Staff2\StaffStorage\users.name \\Staff3\StaffStorage\users.name Find where the users documents are, take ownership using "takeown.exe" and then delete their folders/files I already have finding users and dumping them in a text file figured out I already have taking ownership of their folder and deleting them figured out I just need help on creating and understanding how to search the three servers for the user.name for each user in the text file Your help is much appreciated! Edited July 14, 2012 by Elephant007 Link to comment Share on other sites More sharing options...
Elephant007 Posted July 12, 2012 Author Share Posted July 12, 2012 (edited) I have the following figured out If FileExists ( $Path & "" & $User ) Then RunWait ( "cmd /c takeown " $Path & "" & $User & " /R /Y" ) DirRemove ( $Path & "" & $User, 1 ) Else MsgBox ( 0, "Not Found", "User: " & "'" & $User & "'" & " Not Found" ) EndIf Now if someone can help me understand how to 1) Make the $User value change according to the list of users in the text file 2) How to make $Path alternate through predefind paths like staff1staffstorage staff2staffstorage staff3staffstorage Edited July 12, 2012 by Elephant007 Link to comment Share on other sites More sharing options...
Elephant007 Posted July 12, 2012 Author Share Posted July 12, 2012 Well I kinda figured out something, it's clunky but works, if anyone would like to clean it up for me, I'm all for it! #include <File.au3> #include <Array.au3> RunWait ('cmd /c dsquery user OU="Ready To Delete",OU="Users",DC="domain",DC="org" -o rdn -inactive 17 -limit 0 -disabled > userstodelete.' & @MON & '.' & @MDAY & '.' & @YEAR, "", @SW_SHOW) _ReplaceStringInFile ( 'userstodelete.' & @MON & '.' & @MDAY & '.' & @YEAR, '"','') Local $aInput, $bInput, $cInput $afile = 'userstodelete.' & @MON & '.' & @MDAY & '.' & @YEAR $bFile = 'deletedir.' & @MON & '.' & @MDAY & '.' & @YEAR _FileReadToArray($aFile, $aInput) For $i = 1 to UBound($aInput) -1 MsgBox (0,'',$aInput[$i]) RunWait ( 'cmd /c dir staff1d$*' & $aInput[$i] & ' /s /b >> deletedir.' & @MON & '.' & @MDAY & '.' & @YEAR, '', @SW_HIDE ) RunWait ( 'cmd /c dir staff2d$*' & $aInput[$i] & ' /s /b >> deletedir.' & @MON & '.' & @MDAY & '.' & @YEAR, '', @SW_HIDE ) RunWait ( 'cmd /c dir staff3d$*' & $aInput[$i] & ' /s /b >> deletedir.' & @MON & '.' & @MDAY & '.' & @YEAR, '', @SW_HIDE ) Next _FileReadToArray($bFile, $bInput) For $b = 1 to UBound($bInput) -1 RunWait ( 'cmd /c takeown /f ' & $bInput[$b] & ' /r /d y', '', @SW_HIDE ) DirRemove ( $bInput[$b], 1 ) Next _FileReadToArray($aFile, $cInput) For $c = 1 to UBound($cInput) -1 MsgBox ( 0, '', $cInput[$c]) RunWait ( 'cmd /c dsrm CN="' & $cInput[$c] & '",OU="Ready To Delete",OU="Users",DC="domain",DC="org" -noprompt', '', @SW_HIDE ) Next 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