script to delete Home directory question
what wanted write script delete home directory of disabled users after specific time ( 120 days) .
for i have got script connects ou , deletes disabled user's home directories . believe have modify based on attributes , vbscript date , time management.
here attributes , values that found in ad
account diabled true ( disabled accts)
useraccountcontrol 512 (enabled users)
useraccountcontrol 514 (disabled)
dscorepropagationdata ( showing date of deprovision exact date of deprovision)
usnchanged xxxxxxx
usncreated xxxxxx
whenchanged month/date/year 2:19:50 pm
now can extract date whenchanged attribute , modify script after 120 days of time mentioned in whenchanged the home directory gets deleted?
any appreciated.
##########################
option explicit
dim objou, objuser, objfso, strhomedirectory
set objfso = createobject("scripting.filesystemobject")
' bind ou.
set objou = getobject("ldap://ou=domain users,dc=testlab,dc=com")
' filter on user objects.
objou.filter = array("user")
' enumerate users.
for each objuser in objou
if objuser.useraccountcontrol = 514 then
' retrieve home directory.
strhomedirectory = objuser.homedirectory
' replace %username% value of samaccountname attribute.
strhomedirectory = replace(strhomedirectory, "%username%", _
objuser.samaccountname)
' delete folder.
objfso.deletefolder strhomedirectory
else
wscript.sleep 100
end if
next
hi,
as issue more related scripting, suggest initiate new thread in our official scripting forum better , accurate answer question. community members , support professionals there more familiar scripting , can in more efficient way.
the official scripting guys forum!
http://social.technet.microsoft.com/forums/en-us/itcg/threads
regards,
wilson jia
this posting provided "as is" no warranties, , confers no rights.
Windows Server > Directory Services
Comments
Post a Comment