snyde
March 9th, 2003, 19:42 PM
Hi just having a little play with batch files a home.
does anybody know if this would work , and write an error log at the same time.
I know its a bit long, is there any way to shorten it.
@echo off
rem 1 username i
rem 2 displayname j
rem 3 ?
rem 4 discription k
rem 5 old home drive l
rem 6 home path m
rem 7 profile n
rem 8 logon script o
if "%1" == "" goto help
if "%1" == "-?" goto help
if "%1" == "/?" goto help
echo Errorlog of movem2 created: > error.log
date /T >> error.log
time /T >> error.log
echo if there is nothing below here everything went OK >> error.log
cls
echo Reading In .csv %1 file
echo --------------------------------------------------------------------
for /F "skip=1 delims=, tokens=1,2,3,4,5,6,7,8" %%i IN (%1) do (
echo user: %%i
echo -
echo setting owner of \\fileserver\users\%%i and subdirectories to Administrator
subinacl /subdirectories \\fileserver\users\%%i\* /setowner=administrator
if ERRORLEVEL 1 (echo setting ownership on \\fileserver\users\%%i did not work: %ERRORLEVEL% >> error.log)
echo -
echo giving rights to Domain\administartor on \\fileserver\users\%%i
xcacls \\fileserver\users\%%i /T /E /G DOMAIN\administrator:F;F /y
if ERRORLEVEL 1 (echo setting admin permissions on \\fileserver\users\%%i did not work: %ERRORLEVEL% >> error.log)
echo -
echo moving \%%i to \\SERVER\users\%%i
xcopy s:\%%i e:\users\%%i /E /C /I /H /A /O
if ERRORLEVEL 1 (echo xcopy on %%i did not work %ERRORLEVEL%>> error.log)
echo -
echo setting owner of \\SERVER\users\%%i and subdirectories to %%i
subinacl /subdirectories \\SERVER\users\%%i\* /setowner=%%i
if ERRORLEVEL 1 (echo setting ownership on \\fileserver\users\%%i did not work: %ERRORLEVEL% >> error.log)
echo -
echo setting DOMAIN\administrator permissions on \\SERVER\users\%%i
xcacls e:\users\%%i /T /E /G DOMAIN\administrator:F;F /y
if ERRORLEVEL 1 (echo setting admin permissions on \\SERVER\users\%%i did not work: %ERRORLEVEL% >> error.log)
echo -
echo setting DOMAIN\administrator permissions on \\SERVER\users\%%i
xcacls e:\users\%%i /T /E /G DOMAIN\staff:R;R /y
if ERRORLEVEL 1 (echo setting staff permissions on \\SERVER\users\%%i did not work: %ERRORLEVEL% >> error.log)
echo -
echo setting DOMAIN permissions on \\SERVER\users\%%i
xcacls e:\users\%%i /T /E /G %%i:C;C /y
if ERRORLEVEL 1 (echo setting DOMAIN permissions on \\SERVER\users\%%i did not work: %ERRORLEVEL% >> error.log)
echo -
echo changing profile of %%i
cusrmgr -u %%i -U %%n -h \\SERVER\users\%%i -n %%o +s CanNotChangePassword
if ERRORLEVEL 1 (echo changing of profile on %%i did not work: %ERRORLEVEL% >> error.log)
echo ""
echo ----------------------------------
echo ""
)
echo ""
echo Synchronising DCs
echo --------------------------------------------------------------------
nltest /server:SERVER /pdc_repl
echo Finished, press any key to look at the error log
pause
type error.log
goto exit
:help
cls
echo --------------------------------------------------------------------
echo Script to Move Users and change their directories file permissions
echo Usage:
echo movem [filename] - where filename is a csv.
echo e.g. movem DOMAINusers.csv
echo --------------------------------------------------------------------
:exit
Cheers for looking.
:D :D
does anybody know if this would work , and write an error log at the same time.
I know its a bit long, is there any way to shorten it.
@echo off
rem 1 username i
rem 2 displayname j
rem 3 ?
rem 4 discription k
rem 5 old home drive l
rem 6 home path m
rem 7 profile n
rem 8 logon script o
if "%1" == "" goto help
if "%1" == "-?" goto help
if "%1" == "/?" goto help
echo Errorlog of movem2 created: > error.log
date /T >> error.log
time /T >> error.log
echo if there is nothing below here everything went OK >> error.log
cls
echo Reading In .csv %1 file
echo --------------------------------------------------------------------
for /F "skip=1 delims=, tokens=1,2,3,4,5,6,7,8" %%i IN (%1) do (
echo user: %%i
echo -
echo setting owner of \\fileserver\users\%%i and subdirectories to Administrator
subinacl /subdirectories \\fileserver\users\%%i\* /setowner=administrator
if ERRORLEVEL 1 (echo setting ownership on \\fileserver\users\%%i did not work: %ERRORLEVEL% >> error.log)
echo -
echo giving rights to Domain\administartor on \\fileserver\users\%%i
xcacls \\fileserver\users\%%i /T /E /G DOMAIN\administrator:F;F /y
if ERRORLEVEL 1 (echo setting admin permissions on \\fileserver\users\%%i did not work: %ERRORLEVEL% >> error.log)
echo -
echo moving \%%i to \\SERVER\users\%%i
xcopy s:\%%i e:\users\%%i /E /C /I /H /A /O
if ERRORLEVEL 1 (echo xcopy on %%i did not work %ERRORLEVEL%>> error.log)
echo -
echo setting owner of \\SERVER\users\%%i and subdirectories to %%i
subinacl /subdirectories \\SERVER\users\%%i\* /setowner=%%i
if ERRORLEVEL 1 (echo setting ownership on \\fileserver\users\%%i did not work: %ERRORLEVEL% >> error.log)
echo -
echo setting DOMAIN\administrator permissions on \\SERVER\users\%%i
xcacls e:\users\%%i /T /E /G DOMAIN\administrator:F;F /y
if ERRORLEVEL 1 (echo setting admin permissions on \\SERVER\users\%%i did not work: %ERRORLEVEL% >> error.log)
echo -
echo setting DOMAIN\administrator permissions on \\SERVER\users\%%i
xcacls e:\users\%%i /T /E /G DOMAIN\staff:R;R /y
if ERRORLEVEL 1 (echo setting staff permissions on \\SERVER\users\%%i did not work: %ERRORLEVEL% >> error.log)
echo -
echo setting DOMAIN permissions on \\SERVER\users\%%i
xcacls e:\users\%%i /T /E /G %%i:C;C /y
if ERRORLEVEL 1 (echo setting DOMAIN permissions on \\SERVER\users\%%i did not work: %ERRORLEVEL% >> error.log)
echo -
echo changing profile of %%i
cusrmgr -u %%i -U %%n -h \\SERVER\users\%%i -n %%o +s CanNotChangePassword
if ERRORLEVEL 1 (echo changing of profile on %%i did not work: %ERRORLEVEL% >> error.log)
echo ""
echo ----------------------------------
echo ""
)
echo ""
echo Synchronising DCs
echo --------------------------------------------------------------------
nltest /server:SERVER /pdc_repl
echo Finished, press any key to look at the error log
pause
type error.log
goto exit
:help
cls
echo --------------------------------------------------------------------
echo Script to Move Users and change their directories file permissions
echo Usage:
echo movem [filename] - where filename is a csv.
echo e.g. movem DOMAINusers.csv
echo --------------------------------------------------------------------
:exit
Cheers for looking.
:D :D
