Folder redirection and deleting old folders from server


question other admins using folder redirection gpo.  environment has 30,000 on given day might have 100-300 new users , same amount of deletions. 

the question how go deleting old folders server when users accounts deleted , keep nice , clean. 

thanks input.

i think mean home folder? if see comment.

find attached script can use deleting home folder deleted ad users.

edit "c:\personal\home" matching environment. path home folders!

@echo off
rem query ad home folder names
rem

rem settings
set userhomedir=c:\personal\home
set userlist=%temp%\userlist.txt

rem main
:s0



:s1
echo create userlist

/f %%n in ('dir %userhomedir% /b /a:d') (
echo check ad useraccount: %%n
echo delete folder if not found in ad!
dsquery user -samid %%n | find "cn" & if errorlevel = 1 echo %%n >>.\notfoundinad_%date%_%time:~0,2%-%time:~3,2%-%time:~6,2%.txt & rd /s /q %userhomedir%\%%n
echo done
)

goto end



:end
pause
echo finito


kind regards,

tim
mcitp, mcts, mcsa
http://directoryadmin.blogspot.com

this posting provided 'as is' no warranties or guarantees , confers no rights.

"if thread answered question, please click on "mark answer"




Windows Server  >  Group Policy



Comments

Popular posts from this blog

Edit Group Policy

Hyper-V VM not reaching OS 'Logon' screen

DNS question...