delete Roaming Profile with AD

  • Thread starter Thread starter Adam Murray
  • Start date Start date
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
 
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
 
Back
Top