10 February, 2010

New User Home directory auto-creation

Hi,

New users always come and you do the same things a lot of times.
I wrote a script to simplify the creation and permissions of new user directories.

Just multiply the script for any new personal directory (this one include 2 directories):
=================================================================
echo off
cls
echo This batch will create and set ACL on PST and home Drive
echo.
echo Please type the new user name:
set /P C=

if exist \\server1\pst$\%C% goto pst_exist
echo The pst folder will be created
pause
echo.
md \\server1\pst$\%C%
cacls \\server1\pst$\%C% /E /G "%C%":C
goto check_Homefolder

:pst_exist
echo the PST directory already exist, please check
pause
echo.

:check_Homefolder
if exist \\server2\users\%C% goto H_exist
echo The Home Folder folder will be created
pause
echo.
md \\server2\users\%C%
cacls \\server2\users\%C% /E /G "%C%":C
goto end

:H_exist
echo the Home Folder directory already exist, please check


:end
pause

=========================================================

02 February, 2010

auto backup of active directory gpo

Hi,

This script will automatically backup all GPO in your AD environment, also it will check for errors and mail you about them (with the log file).

First install GPMC.

My sample is using the following:
- 7Zip exe
- Mailit exe
- d:\work\gpo (where the scripts are)
- d:\backup\gpo (where the backup is)

the script:
==================================================
rd D:\Work\GPO_Backup\Temp /s /q
md D:\Work\GPO_Backup\Temp
cscript "C:\Program Files\GPMC\Scripts\BackupAllGPOs.wsf" D:\Work\GPO_Backup\Temp > log.txt
find /i "Backup failed for 0 GPOs" log.txt
if %errorlevel% NEQ 0 goto error
goto OK

:error
echo error in GPO backup
rem === mailit parameters ===
SET MAILIT_SERVER=mail.server
SET MAILIT_FROM=GPO_bk@yourdomain.com
SET MAILIT_TO=s@yourdomain.com
SET MAILIT_SUBJ=Error in GPO Backup
SET MAILIT_MSGTEXT=There are errors in GPO backup, see attached log.
SET MAILIT_ATTACH=D:\Work\GPO_Backup\log.txt
D:\Work\GPO_Backup\MAILIT.exe
goto end

:OK
Set MONTH=%DATE:~4,2%
Set DAY=%DATE:~7,2%
Set YEAR=%DATE:~10,4%
7z.exe a -r "D:\Backup\GPO\GPO_%DAY%-%MONTH%-%YEAR%.zip" D:\Work\GPO_Backup\Temp\*.*
if %errorlevel%==0 goto end

rem === mailit parameters ===
SET MAILIT_SERVER=mail.server
SET MAILIT_FROM=GPO_bk@yourdomain.com
SET MAILIT_TO=s@yourdomain.com
SET MAILIT_SUBJ=Error in GPO Backup (7zip)
SET MAILIT_MSGTEXT=There are errors in GPO backup (7zip)
SET MAILIT_ATTACH=
D:\Work\GPO_Backup\MAILIT.exe
goto end



:end
====================================================

01 February, 2010

Domain Admins and BlackBerry SendAs nightmare

Hi,

Just found a solution for a problem that drove me crazy, My account in AD kept loosing the Inheritance settings and the security kept resetting back. the immediate problem was that without sendas permissions on my account for the blackberry account I could not send any email from it. - I started to loose it...

I have 5 DC's in my network so I tried to see how is setting the permissions but at the end I found that it was the AD itself.

Took me a while to find but it worked.
In a nutshell all admin users will get their permissions reseted if you do not set the inheritance on AdminSHHolder.

Hope it help you before you become crazy... :)