delete Roaming Profile with AD

A

Adam Murray

Is there a way to have Windows 2000 delete the roaming profile and
home folders when a user is deleted from AD?

I walked into a job where no one had ever been disabled or deleted,
(you wonder why the old Admin got fired?) and wanted to see if there
is a script that will take care of this.

Any help?

Thanks
 
J

Jerold Schulman

Is there a way to have Windows 2000 delete the roaming profile and
home folders when a user is deleted from AD?

I walked into a job where no one had ever been disabled or deleted,
(you wonder why the old Admin got fired?) and wanted to see if there
is a script that will take care of this.

Any help?

Thanks

If the home folder on the server was c:\users\username

and the profile folder was c:\profiles\username

you could run the following on the DC.

@echo off
setlocal
for /f "Tokens=*" %%h in ('dir /b /ad c:\users') do set user=%%h&call :chkusr
for /f "Tokens=*" %%p in ('dir /b /ad c:\profiles') do set user=%%p&call :chkpro
endlocal
goto :EOF
:chkusr
set dn="N"
for /f "Tokens=*" %%x in ('dsquery user -samid "%user%" -o dn') do set dn=%%x
if %dn% NEQ "N" goto :EOF
RD /s /q "c:\users\%user%"
@echo %user% home folder deleted.
goto :EOF
:chkpro
set dn="N"
for /f "Tokens=*" %%x in ('dsquery user -samid "%user%" -o dn') do set dn=%%x
if %dn% NEQ "N" goto :EOF
RD /s /q "c:\profiles\%user%"
@echo %user% profile folder deleted.

See tip 7330 and links in the 'Tips & Tricks' at http://www.jsiinc.com

Jerold Schulman
Windows: General MVP
JSI, Inc.
http://www.jsiinc.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top