04 November, 2010

convert excel tesxt to numbers

Hi,

Just wanted to let you know that I found a way to convert numbers that apear as text back to numbers.
If you have a formula that retrieve a number with a text function, when I try to do a vlookup on this it would not work.
Just multiply it by 1 and you will be OK.

19 September, 2010

UnLink GPO script

Hi,

All I wanted is to UnLink a GPO from an OU using a script, not a lot to ask google.
It seems that no one ever need to UnLink a GPO, only delete or link.
So I took the original DeleteGPO.wsf from the GPMC scripts directory and changed it a bit so it would not delete but only unlink the gpo.

Copy the content of the  frame to get the wsf script.



Also published it on my GoogleDocs due to the vbs.

Save it as UnLinkGPO.wsf into "C:\program files\gpmc\scripts" and you have an unlink gpo script.

Enjoy

16 September, 2010

Access server shares under different server name

If you done a file server move you know that as much as you want you cannot be sure if you covered all the places with the old server name.
A simple solution is to change the ip address of the old server after you shut it down to the new one, right?

Well, not that easy, Windows Server has a build in protection against accessing the server with an alias names.

I'm here to tell you that you can bypass that with a small registry key
At the end everything comes to a registry key :)

======================================
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\lanmanserver\parameters]
"DisableStrictNameChecking"=dword:00000001

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

Enjoy

14 September, 2010

The real place to use IE trusted sites via GPO

Hi,

Trusted sites in IE via GPO is a mess, there are several places to insert this settings and the main problem is that they will not work on all versions.

I have the perfect place to use it and I tested it with ver 6,7 and 8 and it worked.

User Configuration -> Administrative Templates -> Windows Components -> Internet Explorer -> Internet Control Panel -> Security Page: Site to Zone Assignment List

Enjoy.

12 September, 2010

Rename the desktop "My Computer" to pc name

Hi,

Using bginfo to add to the user desktop his workstation name ?
Why not just rename the "My Computer" text to the workstation name and that's it ?

2 ways to do it:
- Using VBS Script
- Using GPP

VBS Script:
===================================
Const MY_COMPUTER = &H11&


Set objNetwork = CreateObject("Wscript.Network")
objComputerName = objNetwork.ComputerName
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(MY_COMPUTER)
Set objFolderItem = objFolder.Self
objFolderItem.Name = objComputerName
===================================

GPP:
Just add a registry chnage on the user level:
===================================
Key:        Software\Microsoft\Windows\CurrentVersion\Explorer\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}
Value Name:     (Default)
Value Data:    %computername%
Type:        REG_SZ
==================================

The registry key by the way is (replace 123 with what you want):
==================================
Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}]
@="123"
==================================

Have fun...

07 September, 2010

Utilizing systeminfo to get info on a list of servers or workstation

Hi,

If you have a list of computers (servers or workstations) and need to get some info on them, for example Total Physical Memory you could use my script to get this info.

First put all the computer names in a file and name it servers.txt.
Then decide what property you want to get, the following properties are availble:
Host Name
OS Name:
OS Version
OS Manufacturer
OS Configuration
OS Build Type
Registered Owner
Registered Organization
Product ID
Original Install Date
System Boot Time
System Manufacturer
System Model
System Type
BIOS Version
Windows Directory
System Directory
Boot Device
System Locale
Input Locale
Time Zone
Total Physical Memory
Available Physical Memory
Virtual Memory: Max Size
Virtual Memory: Available
Virtual Memory: In Use
Page File Location(s)
Domain
Logon Server

(will work with only property that the output is 1 line)

The script:
===================================
@echo off
echo.
echo Type the SystemInfo attribute
echo you want to check:

set /P C=
del "%C%.txt"
for /f %%A in (servers.txt) do (
echo Server: %%A >> "%C%.txt"
systeminfo /s \\%%A | find "%C%:" >> "%C%.txt"
echo ------------------------------------------------------------------ >> "%C%.txt"
)
==================================

enjoy

06 September, 2010

SQL Express (MSDE) automatic backup script

Hello all,
You may have instances of SQL Express or in it's previus version MSDE due to small applications or just to save some moeny.
The main problem is to back them up in a central location and get alerts if something goes wrong.

My script is using the following external tools:
1. osql.exe - just install studio express
2. mailit.exe - a command line mailing program, part of NUTS suite.

The things you need to do before:
1. make sure that the sql instance supports integrated security (http://msdn.microsoft.com/en-us/library/ms188670.aspx)
2. document the server names and instance name
3. create a shared central location for the backup destination (security of the directory should include the computer account that you are backing up with write permissions)
4. create a sql backup script for every DB you want to backup (replace the bold with your data):
==============================
BACKUP DATABASE [DBNAME] TO  DISK = N'\\server\share$\Filename.bak' WITH NOFORMAT, NOINIT, NAME = N'BESMGMT-Full Database Backup', SKIP, NOREWIND, NOUNLOAD,  STATS = 10
GO
==============================


The script:
in this example I backup 3 DB's on 3 deferent servers.
replace the BOLD with your data
==============================
set backupexec=yes
set epo=yes
set bes=yes

osql -S servername\bkupexec -E -i D:\Work\DB_Backup\Scripts\BackupexecDB.sql -o D:\Work\DB_Backup\Logs\backupexec.log

find "BACKUP DATABASE successfully processed" D:\Work\DB_Backup\Logs\backupexec.log
if %errorlevel% NEQ 0 (set Backupexec=no)

osql -S servername\eposerver -E -i D:\Work\DB_Backup\Scripts\ePO.sql -o D:\Work\DB_Backup\Logs\ePO.log

find "BACKUP DATABASE successfully processed" D:\Work\DB_Backup\Logs\ePO.log
if %errorlevel% NEQ 0 (set epo=no)

osql -S servername\besmgmt -E -i D:\Work\DB_Backup\Scripts\BES.sql -o D:\Work\DB_Backup\Logs\BES.log

find "BACKUP DATABASE successfully processed" D:\Work\DB_Backup\Logs\BES.log
if %errorlevel% NEQ 0 (set bes=no)

set body=
if "%backupexec%"=="no" (set body=BackupExec)
if "%epo%"=="no" (set body=%body%, ePO)
if "%bes%"=="no" (set body=%body%, BES)
set att=
if "%backupexec%"=="no" (set att=D:\Work\DB_Backup\Logs\backupexec.log)
if "%epo%"=="no" (set att=%att%,D:\Work\DB_Backup\Logs\ePO.log)
if "%bes%"=="no" (set att=%att%,D:\Work\DB_Backup\Logs\BES.log)
if "%body%"=="" goto end

rem === mailit parameters ===
SET MAILIT_SERVER=mailserver
SET MAILIT_FROM=db_bk@yourdomain.local
SET MAILIT_TO=your-email@yourdomain.local
SET MAILIT_SUBJ=Error in DB Backup (%body%)
SET MAILIT_MSGTEXT=There are errors in DB backup of: %body%
SET MAILIT_ATTACH=%att%
D:\Work\DB_Backup\MAILIT.exe

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

Enjoy

05 September, 2010

Delete local hotfix folders script (Windows XP only)

Deploying hotfixes ?
Have Windows XP in your environment ?

Here is a vbs script to delete all hotfix folders, just deploy it via GPP or any other method:
==================================
dim filesys, f
Set objShell=CreateObject("WScript.Shell")
Set objArgs = WScript.Arguments
'FolderName =objArgs(0) 'optional with parameter
Set fso=createobject("scripting.filesystemobject")
Set f = fso.GetSpecialFolder(0)
FolderName = f

Set fld_root = fso.GetFolder(FolderName)
For Each fld_sub In fld_root.SubFolders
  If (InStr(fld_sub.Name,"$")=>1) Then
       if fld_sub.Name ="$hf_mig$" Then
       Else
       'WScript.Echo "Deleting " & Foldername & "\" & fld_sub.Name
       fld_sub.delete
       End If
  End If
 Next
==================================

Enjoy...

02 September, 2010

Simple Script to disable UAC on vista/W7

Hi,


The prompt for approval is annoying? Try this simple script in batch...

(It will restart the PC and you must run it with administrator privileges)

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

@echo off

reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA /t REG_dword /d 0 /f

if %errorlevel%==0 (goto restart)

echo Unable to set the registry key...

pause

goto end


:restart

shutdown -r -f -t 30 /c "UAC Disabled, Restarting..."

quit


:end

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


enjoy

31 August, 2010

SCOM - a link to an article I wrote on How to Play Sound Alerts on SCOM Console

One of the problems with System Center Operation Manager console is the lack of sound alerts.
I wrote an article a while back on how to implement a sound alert for events.

Here is the link from perti.co.il - http://www.petri.co.il/play-sound-alerts-on-microsoft-system-center-operations-manager-console.htm

Enjoy

29 August, 2010

Xen Server environment mapping script

Hello,

do you want a basic xen server environment mapping script ?, you got it.
for starting it will list all the hosts and guests, in the future I will add UUID and more...

================================
echo off
set user=[]
set password=[]
set server=[]

del auto_host_list.txt /q
del auto_vm_list.txt /q

"C:\Program Files\Citrix\XenCenter\xe.exe" -s %server% -u %user% -pw %Password% host-list params=name-label,uuid >auto_host_list1.txt
for /f "tokens=1,2,3,4 delims=( " %%A in (auto_host_list1.txt) do (echo %%D >> auto_host_list.txt)

"C:\Program Files\Citrix\XenCenter\xe.exe" -s %server% -u %user% -pw %Password% vm-list params=name-label >auto_vm_list1.txt
for /f "tokens=1,2,3,4 delims=( " %%A in (auto_vm_list1.txt) do (
if NOT %%D==Control echo %%D  >> auto_vm_list.txt
)

del auto_host_list1.txt /q
del auto_vm_list1.txt /q
================================

26 August, 2010

XenServer disaster recovery script in batch

Hi all,
I wanted to make my life easier when the disaster will hit (and between you and me it allays a meter of time) so I wrote a menu driven disaster recovery script.
The script is covering:
  1. Pool Master failure
  2. Host Member Failure
  3. resetting the power state of VM's
  4. Recovering them to another HOST
My goal was giving a simple name based actions rather than using UUID's.

You will need 2 more files that create your environment:
  1. host_list.txt - all the hosts and their role, one each line. example: [servername, member]
  2. vm_list.txt - all the vm
Those 2 files are case sensitive so be sure to write the names correctly.
Note: in host_list.txt the role should be in lower letters (member/master)

To help you I saved it also as a GoogleDoc.

Any comments/improvements will be welcomed...

================================
Echo off
title "Xen Recover for 5.5 - at any time hit Cntrl+C and then Y to exit the script."

set user=[]
set password=[]
set server=[]

cls

echo This is a disaster recover script for Xen Server.
echo.
echo Host Infrastructure:
for /f "tokens=1,2 delims=," %%A in (Host_list.txt) do (echo Host: %%A - %%B)
echo.
echo Guest Machines:
for /f %%A in (VM_list.txt) do (echo VM: %%A)
echo.
echo.
echo is this OK ? (1-yes)
set /P C=
if %C%==1 goto continue
goto EOF

:continue


cls
echo Good.
echo What do you want to do ?
echo 1 - Recover from pool master failure
echo 2 - Recover from member failure
set /P C=
if %C%==1 goto master_failure
if %C%==2 goto member_failure


:master_failure
echo To which server to you want to transfer the pool master role ? (IP address only)
set /P C=
echo transfer pool master to %C%
pause
echo pool move to %C%
set server=%C%
echo on
"C:\Program Files\Citrix\XenCenter\xe.exe" -s %server% -u %user% -pw %Password% pool-emergency-transition-to-master
"C:\Program Files\Citrix\XenCenter\xe.exe" -s %server% -u %user% -pw %Password% pool-recover-slaves
Echo off
:master_failure_2
echo Type the new pool master server name: (case sensitive)
for /f "tokens=1,2 delims=," %%A in (Host_list.txt) do (
    if %%B==member (echo Host: %%A)
)
set /P xenhostname=
set caller=master_failure_3
goto check_host
:member_failure_3
if "%host_ok%"=="yes" (goto member_failure_4)
echo The Host name is not on the list
pause
goto member_failure_2
set failed-host=%xenhostname%
goto power_reset


:member_failure
echo Which member server has failed ? (type the name - case sensitive)
echo Showing only members.
for /f "tokens=1,2 delims=," %%A in (Host_list.txt) do (
    if %%B==member (echo Host: %%A)
)
echo.
echo It seems that the following host is down:
"C:\Program Files\Citrix\XenCenter\xe.exe" -s %server% -u %user% -pw %Password% host-list host-metrics-live=false params=name-label
set /P xenhostname=
set caller=member_failure_2
goto check_host
:member_failure_2
if "%host_ok%"=="yes" (goto member_failure_3)
echo The Host name is not on the list
pause
goto member_failure
:member_failure_3
set failed-host=%xenhostname%
goto power_reset


:power_reset
echo resetting the power state on the machines that was on the failed host [%failed-host%]
pause
echo get host uuid
"C:\Program Files\Citrix\XenCenter\xe.exe" -s %server% -u %user% -pw %Password% host-list name-label=%xenhostname% --minimal > host_uuid.txt
set /p host_uuid=
echo resetting power on VM's residing on %xenhostname% [uuid=%host_uuid%]
echo on
"C:\Program Files\Citrix\XenCenter\xe.exe" -s %server% -u %user% -pw %Password% vm-reset-powerstate resident-on=%host_uuid% --force --multiple
Echo off
goto VM_recover

:vm_recover
echo Which VM do you need to recover ?
for /f %%A in (VM_list.txt) do (echo %%A)
echo it seems that the following VM's were on the failed host:
"C:\Program Files\Citrix\XenCenter\xe.exe" -s %server% -u %user% -pw %Password% vm-list is-control-domain=false resident-on=%host_uuid% params=name-label
set /P vmname=
set caller=vm_recover_2
goto check_vm
:vm_recover_2
if "%vm_ok%"=="yes" (goto vm_recover_3)
echo The VM name is not on the list...
pause
goto vm_recover
:vm_recover_3
"C:\Program Files\Citrix\XenCenter\xe.exe" -s %server% -u %user% -pw %Password% vm-list name-label=%vmname% --minimal > vm_uuid.txt
set /p vm_uuid=
:vm_recover_4
echo Recover to which HOST ?
for /f %%A in (host_list.txt) do (echo %%A)
echo.
echo Note: %failed-host% has failed and cannot be choosen.
set /P xenhostname=
if "%xenhostname%"==%failed-host% (
    echo %failed-host% has failed and cannot be choosen.
    goto :vm_recover_4
)
set caller=vm_recover_5
goto check_host
:vm_recover_5
if "%host_ok%"=="yes" (goto vm_recover_6)
echo The HOST name is not on the list...
pause
goto vm_recover_4
:vm_recover_6
"C:\Program Files\Citrix\XenCenter\xe.exe" -s %server% -u %user% -pw %Password% host-list name-label=%E% --minimal > host_uuid.txt
set /p host_uuid=
echo recover %vmname% [%vm_uuid%] on %xenhostname% [%host_uuid%]
echo on

"C:\Program Files\Citrix\XenCenter\xe.exe" -s %server% -u %user% -pw %Password% xe vm-param-set uuid=%vm_uuid% affinity=%host_uuid%
Echo off
echo.
echo Recover another VM ? (1-yes)
set /P C=
if %C%==1 goto vm_recover
goto end



rem *** general functions ***
:check_host
set host_ok=
for /f "tokens=1 delims=," %%A in (Host_list.txt) do (
    if "%xenhostname%"=="%%A" (set host_ok=yes)
)
goto %caller%

:check_vm
set vm_ok=
for /f %%A in (vm_list.txt) do (
    if "%vmname%"=="%%A" (set vm_ok=yes)
)
goto %caller%


:end

rem *** cleanup ***
del host_uuid.txt /q
del vm_uuid.txt /q
pause

:EOF
echo *** written by snir hoffman http://snirh.blogspot.com ***

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

17 August, 2010

Xen Server Automatic Host backup script using batch

Hi,

You can never be too carefull, here is an automated backup script for xen server host.
Be careful, it can reach to 1G... (Mine did).

as always you will need a list file with the names of the xen hosts (case sensitive), name it host_list.txt.
and the following: (this will keep 2 versions, you can remove those lines if you want)
replace [] with your data.
====================================
for /f %%A in (host_list.txt) do (
del "D:\Backup\XenServer\OLD_%%A_Backup.bak" /q
ren D:\Backup\XenServer\%%A_Backup.bak Old_%%A_Backup.bak
"C:\Program Files\Citrix\XenCenter\xe.exe" -s [server ip] -u [user] -pw [password] host-backup host=%%A file-name=D:\Backup\XenServer\%%A_Backup.bak
)
====================================

04 August, 2010

Automatic script for Xen Coalesce (gain space back after using snapshots)

If you are using snapshots in XenServer you may noticed a spaced beed used on the storage that you cannot explained.
This is due to using snapshots. After you create the initial snapshot xen will continue writing to it even if it is not there.
To reclaim the space the VM's VDI need to go a proccess named "Coalesce" which integrates the data from the snapshot into the original VDI.

I used article CTX123400 to base my script on.
Also you will need to download "plink".

3 files:
  1. VM_List.txt - a list of the machine names (case sensitive)
  2. Step1.cmd
  3. Step2.cmd

Step1.cmd: replace [] with your own data
==========================
echo off
set user=[user]
set password=[password]
set server=[server ip]
del log_Coalesce.txt /q
for /f %%A in (vm_list.txt) do (step2.cmd %%A >>log_Coalesce.txt)
==========================

Step2.cmd:
==========================
title ***** Working on %1 *****
echo ***** Start working on %1 *****
echo.echo Start at:
echo %date% - %time%
set vm_uuid=
"C:\Program Files\Citrix\XenCenter\xe.exe" -s %server% -u %user% -pw %Password% vm-list name-label="%1" --minimal > vm_uuid.txt
set /p vm_uuid=

plink -ssh %server% -l %user% -pw %password% coalesce-leaf -u %vm_uuid%
echo.
echo %date% - %time%
echo ***** End working on %1 *****
echo.
============================


Enjoy

25 July, 2010

Delete all snapshots by name (XenServer)

I posted a blog a while back on how to delete all snapshots from SR.
I found it not working 100%, so I wrote a new script that deletes all Snapshots by name.
So if you use the backup script I wrote you can use this as a pre-step to delete old snapshots.

Here it is:
====================================================

echo === deleting old snapshot ===
set user=[user]
set password=[password]
set server=[IP]
echo Start at:
echo %date% - %time%
:start
C:\Progra~1\Citrix\XenCenter\xe.exe -s %server% -u %user% -pw %Password% template-list name-label=4Backup --minimal > Old_tempates.txt
for /f "tokens=1 delims=," %%G in (Old_tempates.txt) do (
if [%%G] EQU [] (goto end) else (
C:\Progra~1\Citrix\XenCenter\xe.exe -s %server% -u %user% -pw %Password% template-param-set is-a-template=false uuid=%%G
C:\Progra~1\Citrix\XenCenter\xe.exe -s %server% -u %user% -pw %Password% vm-uninstall uuid=%%G force=true
goto start
)
)

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

enjoy...

21 July, 2010

Remote enable RDP on 2003 and XP

Remote desktop is not enabled by default with Windows XP and Win 2003 Server. 
However, you can connect through the network to a remote registry and enable it.
The key you need is :
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server
 

Change fdenyTSconnections from 1 to 0 and then remotely connect to the PC you need. 

You can also do "reg add \\[machine name]\HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server /v fdenyTSconnections /t REG_DWORD /d 0 /f"
replacing [] woth your remote machine name.


I do not need to tell you that you need admin rights on the remote machine to do this...



19 July, 2010

Automatic script for Zip and delete files

I have a SQL backup directory and wanted a script to auto zip the files and delete them after a succesful zipping.

Here you go (using 7-zip):
==============================
FOR %%f in (*.bak) do (
7z.exe a %%f.7z  %%f
if %errorlevel%==0 (del %%f /q)
)
==============================

easy, no ?

08 July, 2010

Live Xen Backup using a batch job

Hi,

I like batch jobs more than VBS, I'm old fashion. :)
I wrote a script to backup Xen Server guests machines using batch.

The script will clean old snapshots with a single SR, then will try to create a snapshot with  quiesce (using VSS) and if not successful, will do a regular backup.

It contains 4 files:
1. VM_List.exe - the list of the vm names you want to backup (one per line)
2. Step1.cmd - the file you need to run, will enumerate the list of machines to backup
3. Step2.cmd - a command to delete all the old snapshots (more complicated that it sounds)
4. Step3.cmd - the actual backup script

and now the content of the files (VM_List.exe I believe you can create yourself):
Replace [] with your data.

Step1.cmd:
=====================================
echo off
set server=[pool master ip]
set user=root
set password=[password]
call XenBackup-Snapshots-step2.cmd > log_snap.txt
for /f %%A in (vm_list.txt) do (XenBackup-Snapshots-step3.cmd %%A >>log_snap.txt)
=====================================

Step2.cmd: (I assume you have 1 SR, if you have more just replicate this script per SR)
=====================================
echo === deleting old snapshot ===
echo Start at:
echo %date% - %time%
:start
C:\Progra~1\Citrix\XenCenter\xe.exe -s %server% -u %user% -pw %Password% vdi-list is-a-snapshot=true sr-uuid=[sr-uuid] --minimal > vdi.txt
for /f "tokens=1 delims=," %%G in (vdi.txt) do (
if [%%G] EQU [] goto end
C:\Progra~1\Citrix\XenCenter\xe.exe -s %server% -u %user% -pw %Password% vdi-destroy uuid=%%G
echo.
goto start
)
:end
=====================================

Step3.cmd:
=====================================
echo off
setLocal EnableDELAYedExpansion
title ***** Working on %1 *****
echo ***** Start working on %1 *****
echo.
echo === Start Backup for %1 ===
echo.
echo Start at:
echo %date% - %time%
set vm_uuid=
set template_uuid=
"C:\Program Files\Citrix\XenCenter\xe.exe" -s 192.168.120.10 -u %user% -pw %Password% vm-list name-label="%1" --minimal > vm_uuid.txt
set /p vm_uuid=

set snapshot-type=vm-snapshot-with-quiesce
:snapshot
C:\Progra~1\Citrix\XenCenter\xe.exe -s %server% -u %user% -pw %Password% %snapshot-type% new-name-label=backup uuid=%vm_uuid% > template_uuid.txt
set /p template_uuid=

set C=-
set N=
:loop
if !template_uuid:~0^,1! equ !C! (
set /a N+=1
)
if "!template_uuid:~1!" neq "" (
set template_uuid=!template_uuid:~1!
goto :loop
)
if !N! NEQ 4 do (
if %snapshot-type%==vm-snapshot goto no_snap else
set snapshot-type=vm-snapshot
goto snapshot
)

C:\Progra~1\Citrix\XenCenter\xe.exe -s %server% -u %user% -pw %Password% template-export template-uuid=%template_uuid% filename=d:\VM_Backup\%1.xva
echo.

:no_snap
echo NO SNAPSHOT !!!
:emd
echo.
echo %date% - %time%
echo ***** End working on %1 *****
echo.

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

07 July, 2010

Automated internet speed check (using external FTP)

Hi,

I wanted to check the internet speed every week to be sure that we don't have any reduction from what the ISP should give us.

Asked the ISP for a FTP location and wrote a script that gives me a log each week with a download/upload speed.

The script has 2 files:
1. the FTP script
2. the CMD file

Instructions:
- name the ftp script transfer.txt
- replace the [] in transfer.txt with your info
- create a file for transfer and save it as c:\temp\TestFile.dat. (I used Lan Speed Test)
- You can edit the script to fit your environment

CMD file:
===========================================
echo off

rem *** create a unique log file by date ***
Set MONTH=%DATE:~4,2%
Set DAY=%DATE:~7,2%
Set YEAR=%DATE:~10,4%
set output=%YEAR%-%MONTH%-%DAY%.txt

echo The test was performed on the %DATE% at %TIME% > %output%
echo. >> %output%

rem *** run the test ***
ftp -s:Transfer.txt > ftp_output.txt

rem *** extract the important lines from the log ***
for /f "tokens=1,2,3,4,5,6,7 delims= " %%A in (ftp_output.txt) do (
if "%%A"=="ftp:" (echo %%A %%D %%G >> %output%)
)
====================================================
after you have the file you can mail it or just archive it.

Transfer.txt (replace the [] with your info):
====================================================
open [your.ftp.server]
[Username]
[password]
put c:\temp\TestFile.dat TestFile.dat
get TestFile.dat c:\temp\TestFile.dat
quit
====================================================

the log file would look like this:
====================================================
The test was performed on the Tue 07/06/2010 at 11:30:10.78

ftp: received 2780.83Kbytes/sec.

ftp: sent 1874.44Kbytes/sec.
====================================================

Bye...

04 July, 2010

Difference between Microsoft Access Runtime and Retail

Hi,

One of my clients asked me to give him a list of all the machines that runs MS Access Retail and list of MS Access Run-time.

I looked and looked and couldn't find any differences between the versions. The files are the same, the DLL's are the same. I was frustrated.

I used procmon.exe from sysinternal and found that there is no difference in the actual files but only registry settings !!!

Here there are:

[HKEY_CLASSES_ROOT\Licenses\73A4C9C1-D68D-11d0-98BF-00A0C90DC8D9\11.0\Runtime]
@="rldvasjwmvjfrcatkskctmtjahdnkccdgjds"


[HKEY_CLASSES_ROOT\Licenses\73A4C9C1-D68D-11d0-98BF-00A0C90DC8D9\11.0\Retail]
@="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

30 June, 2010

Open Google in english - always...

Hi,

Localization is nice but not when I get Google, I like my Google in English.

Found a way to do this, just open the following link and it will always open in English:
http://www.google.com/ncr, I think that NCR stands for No Character Recognition but you never know.

Snir

15 June, 2010

Solve the drive maps disconnection problem

Hi,
I had a problem that the users kept disconnecting, found a registry key to keep the connection connected up to 18 hours.

HKLM\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters

Name: KeepConn
Type: REG_DWORD
Value: 1–65535

The value is in seconds and the default is 600 (10 min).

Enjoy.

MS Link

14 June, 2010

Disable TCP Chimney

I know a lot of places has it, but I always search for it, just a quick note on how to disable/enable TCP chimney:

- Using registry:
In HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters

- EnableTCPChimney
Type: REG_DWORD
Values: 1 (enabled) 0 (disabled)
- EnableRSS
Type: REG_DWORD
Values: 1 (enabled) 0 (disabled)
- EnableTCPA
Type: REG_DWORD
Values: 1 (enabled) 0 (disabled)

Using Netsh:
- Netsh int ip set chimney ENABLED
- Netsh int ip set chimney DISABLED

What is TCP Chimney: http://support.microsoft.com/kb/951037

Info based on : http://support.microsoft.com/kb/912222

25 May, 2010

Never be prompted for a password again via RDP

Hi,

I connect a lot using RDP to my servers, each time need to remember to save the connection or retyping the password.

A small registry key would force ALL RDP connections to autologin using your current username and... wait for it... PASSWORD!!!

HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows NT\Terminal Services\fPromptForPassword
registry value should be set to 0

there is also a KB Article to do this using GPO.

Bye...

20 May, 2010

Central Fortigate Backup script

Hi,

I have several sites with fortigate as the firewall and a lot of on the fly changes on them, I wrote a script for automatic backup of the fortigates, it uses the following tools:
- PLINK
- 7zip

You need to prepare a FTP site to backup to, I created the site on the machine that runs the backup and this way I can zip it up after the backup completes.

just run it once a day and it will keep history for each day.
change each [] field with your values.


===========================================================
echo off
set user=[username]

rd D:\Backup\Fortigate\Temp /s /q
md D:\Backup\Fortigate\Temp

:1st
set pass=[password]
set hostIP=x.x.x.x
set hostName=[Fortigate Name]
set next=2nd
goto start_bk

:2nd
set pass=[password]
set hostIP=x.x.x.x
set hostName=[Fortigate Name]
set next=3rd
goto start_bk

:3rd
set pass=[password]
set hostIP=x.x.x.x
set hostName=[Fortigate Name]
set next=7zip
goto start_bk

:start_bk
echo === Backing up %hostName% at %hostIP% ===
echo execute backup config ftp /fortigate/Temp/%hostname%_%hostIP%.conf [traget ftp ip] [ftp user] [ftp password] > Command.txt
plink -ssh %hostIP% -l %user% -pw %pass% -m D:\Work\Fortigates_Backup\Command.txt
del command.txt /q
echo.
goto %next%

:7zip
Set MONTH=%DATE:~4,2%
Set DAY=%DATE:~7,2%
Set YEAR=%DATE:~10,4%
7z.exe a -r "D:\Backup\Fortigate\FG_%DAY%-%MONTH%-%YEAR%.zip" D:\Backup\Fortigate\Temp\*.*

:end

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

have fun.

12 May, 2010

IP address convert to full numbers

Hi,

don't know about you but I keep a record of all of my IP on a spreadsheet, did you try to sort them ? - it will sort the 1 and then the 100 numbers because it sees them as test and not numbers.

Created a cool small spreadsheet that helps you convert all your IP to a structure of xxx.xxx.xxx.xxx format.
The GoogleDoc Link

Enjoy.

(By the way, it will work with xxx.xxx at at the start - my all network is 192.168 so...)

11 May, 2010

Delete all snapshots in a SR (XenServer)

Hi,

Wrote a little script to centrally delete all snapshots from a SR on XenServer.
I noticed that although you delete a snapshot an entry still remains on the SR.
Since I have 1 main SR I wrote a script to delete all of them before the backup process begins (later when it will be ready I'll post it).

================================================
echo === deleting old snapshot ===
echo Start at:
echo %date% - %time%
:start
C:\Progra~1\Citrix\XenCenter\xe.exe -s [Pool Master / Server IP] -u [user] -pw [password] vdi-list is-a-snapshot=true sr-uuid=[sr uuid] --minimal > vdi.txt
for /f "tokens=1 delims=," %%G in (vdi.txt) do (
if [%%G] EQU [] goto end
C:\Progra~1\Citrix\XenCenter\xe.exe -s [Pool Master / Server IP] -u [user] -pw [password] vdi-destroy uuid=%%G
echo.
goto start
)

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

and it works great...

06 May, 2010

Resizing a SR on XENServer 5.5

I needed to re-size an SR in XenServer, for some reason all the articles (including the one on citrix web site) did not work.

Finally I did the following steps and it started working...

1. Shut down all virtual machines on the SR.
2. Get the SR UUID with #xe sr-list name-lable=[SR anme]
3. Extend the Volume on the Storage
4. In CLI Run #iscsiadm -m node –R (to reinitialize the iSCSI) on the pool master
5. In the CLI run #pvresize --setphysicalvolumesize 40G /dev/sda1 (when replacing the amount of Gb and the location of the SR)
6. Run in the CLI #xe sr-scan uuid=[uuid]
7. Run #pvs to be sure the new size is here
8. Power on the Virtual Machines.



Simple, no ?

VMWare workstation virtual NIC has no access

Hi,

Had a problem with VMWare Workstation for some time now, started a vm and the nic could not connect to the network, only a restart to my laptop did the trick.

Took me a while to find that this will happen after a hibernation, looked a bit more and found the solution:


=====================================
net stop vmnetbridge
net start vmnetbridge
pause
=====================================

you can run it even if the VM is running and it will fix the NIC problem.

05 May, 2010

Microsoft Online Services Signin application will not resolve the user

Had a problem for a very long time now.
I moved few of my china users from my internal exchange server to use cloud based email provided by Microsoft.

The sign-in application should create a redirection of the auto-discovery service to the online service but it seems that they have a bug in the program, If I use the registry override for use with Closest DC (KB319206) the autodiscover override does not work. (I deployed it due to my multi-site environment).

HKEY_CURRENT_USER\Software\Microsoft\Exchange\Exchange Provider\

Changed the "Closest DC" dward to “0” and all is OK.

29 April, 2010

Symantec Backup Exec remote agent manual update

Hi,

I had problems with remote updating BackupExec remote Agent, some update went OK but others just failed.
Symantec will not give an easy way to manually deploy those updates and when they multiply it's a lot of work...

I found an easy way to it, follow this steps:

1. copy the following folder localy: "\\[BEServerName]\c$\Program Files\Symantec\Backup Exec\Agents\RAWS32\Updates" (RAWS32 should be replaced with RAWSX64 depends on your OS)

2. create a CMD file in that directory and copy the following to the file:

rem ===== this will list all BE Agent updates in dates order and will apply them ====
dir /OD /B *.msp > files.txt

for /f %%A in (files.txt) do (msiexec /update %%A /passive /norestart)

rem ==== the end (easy no ?) =====

3. run the CMD file...

08 March, 2010

Notepad++ run the script with cscript

Hi,

I needed a way to run a vbs script i was working on using Notepad++ and I all the time had to go to a cmd screen and run it.
Found a cool way to ease my pain, in the "Run" menu there is an option to save a command. Just type the following and a CMD window will open and will run the vbs in cscript.

=================================================================
cmd /k cd /d "$(CURRENT_DIRECTORY)" && Cscript "$(FILE_NAME)"
=================================================================

if you would like to leave the window open each time use the following:
=================================================================
cmd /c cd /d "$(CURRENT_DIRECTORY)" && Cscript "$(FILE_NAME)" && pause
=================================================================

Bye...

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
================================================================