04 March, 2010

reset the offline files and configuration

Just had hard time finding a solution for Offline files that the server is no longer sharing the files.
Very simple:

REG ADD "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\NetCache" /v FormatDatabase /t REG_DWORD /d 1 /f

Restart the machine and reconfigure the sync...

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... :)

31 January, 2010

Restart BlackBerry server services

Just another thing I caught in one of the days, wanted to share with you:

================================================
net stop "BlackBerry Controller"
net stop "BlackBerry Dispatcher"
net stop "BlackBerry Router"
net stop "BlackBerry Synchronization Service"
net stop "BlackBerry Policy Service"
net stop "BlackBerry MDS Connection Service"
net stop "BlackBerry Attachment Service"
net stop "BlackBerry Alert"

pause

net start "BlackBerry Router"
net start "BlackBerry Dispatcher"
net start "BlackBerry Controller"
net start "BlackBerry Synchronization Service"
net start "BlackBerry Policy Service"
net start "BlackBerry MDS Connection Service"
net start "BlackBerry Attachment Service"
net start "BlackBerry Alert"
pause



rem === based on kb: http://www.blackberry.com/btsc/dynamickc.do?externalId=KB13718&sliceId=SAL_Public&command=show&forward=nonthreadedKC&kcId=KB13718 ===

20 January, 2010

NIC Disable enable script...

Small script to disable and enable the NIC:

==================================================================
netsh int set int name="Local Area Connection" admin=DISABLED
if %errorlevel% NEQ 0 goto no_disable

netsh int set int name="Local Area Connection" admin=ENABLED
if %errorlevel% NEQ 0 goto no_enable
goto end


:no_disable
echo Could not disable
goto end

:no_enable
echo Could not enable

:end
pause
================================================================

31 December, 2009

Simple delete of subdirectories only

Hi,

Just found a solution to delete subdirectories from the root of a disk.
Normally to delete a subdirectory you use the RD command but you cannot delete the root folder so you have a problem.

Not anymore...

================================
dir f: /B > dir.txt
for /f %%f in (dir.txt) do (rd f:\%%f /S /Q)
del dir.txt /q
================================

Enjoy.