Wednesday 6 April 2005

Quickly reset users home directory permissions

This is not my work but that of Shawn Hopkins that I found on Google Groups.

I faced a situation where my users home and profile directories were ok but the users had simply lost their permissions (importing foreign disk, long story....). Shawn's scripts were written for NT but they worked fine with Server 2003. I did the following:

Gave Administrators full access to d:\home and d:\profiles.

Ran this:
net user /domain >> users.txt

Then ran this script:
for /f "eol=; tokens=1,2*" %%i in (users.txt) do cacls d:\home\%%i /T /E /G %%i:C
for /f "eol=; tokens=1,2*" %%j in (users.txt) do cacls c:\home\%%j /T /E /G %%j:C
for /f "eol=; tokens=1,2*" %%k in (users.txt) do cacls c:\home\%%k /T /E /G %%k:C

Then this script:
for /f "eol=; tokens=1,2*" %%i in (users.txt) do cacls d:\profiles\%%i /T /E /G %%i:C
for /f "eol=; tokens=1,2*" %%j in (users.txt) do cacls d:\profiles\%%j /T /E /G %%j:C
for /f "eol=; tokens=1,2*" %%k in (users.txt) do cacls d:\profiles%%k /T /E /G %%k:C

No comments:

Post a Comment