Wednesday, 29 June 2011

Backup a file using powershell script

Some critical files that I modify each day had to be backed up to a secure location, in case the file gets corrupted I can go to the archive and get the most recent backup.

I created a powershell script to do this. The script is pasted below.
#file name backup.ps1
$TodaysDateFormatted = Get-Date -format
if(Test-Path $PathToGoalsSheet)
if(Test-Path $PathToGoalsSheet\$FileToBeBackedUp)
Write("Creating folder ["+$BackupFolderName+"]...")
New-Item $PathToGoalsSheet\$BackupFolderName -type directory
Write("Copying File ["+ $FileToBeBackedUp +"] into ["+$BackupFolderName+"]...")
Copy-Item "$PathToGoalsSheet\$FileToBeBackedUp" "$BackupPath\$BackupFolderName"
Write("Could not find file ["+ "$PathToGoalsSheet\$FileToBeBackedUp" +"]!")
Write("The path ["+$PathToGoalsSheet+"] does not exist!")

The command to run this script file, I typed in a batch file (.bat), so I can run the powershell file (or schedule a task to run the batch file on a daily basis). The code in the batch file is as given below.

rem file name backup.bat
@echo off
set scriptHomePath=C:\PowerShell Scripts\
set backupFileScript=%scriptHomePath%backup.ps1
powershell -NoLogo -File "%backupFileScript%"

Thursday, 23 June 2011

Calendar Active Exchange Sync on Android : Client/server conversion error

I happened to edit one of the occurences of a recurring meeting, in my mobile's calendar. My mobile is having Android Froyo (Android 2.2). After editing, I connected my phone to wifi and tried to sync the calendar. But when I tried to sync, the calendar will not successfully sync, but shows the error "Client/server conversion error".

This is how I solved the problem:
  1. In my phone, I navigated to Settings > Applications > Manage Applications. Selected 'All' tab which shows all the applications.
  2. After that I scrolled to Calendar in the list I did the following
    1. Seleted and opened the Calendar from the list.
    2. Clicked on 'Clear Data'.
  3. I repeated steps above 2(a) and 2(b) for 'Calendar Storage', 'Calendar Sync Adapter' & 'Calendar Widget' in the list of applications, that I had opened in step 1.
  4. I clicked the 'Home' button on my phone to go to the home screen. Then again navigated to Settings > Accounts & Sync > Exchange ActiveSync.
    1. Unchecked 'Sync calendar'
    2. Clicked 'Sync now' (synced Mail & Contacts only)
    3. Checked 'Sync calendar'
    4. Clicked 'Sync now' again. (synced Mail, Calendar & Contacts)
The error has never come back again.

But not sure why a calendar item if I modify in my phone cannot be synced to the calendar in the exchange server.

Thursday, 16 June 2011

Adverts display products related to my recent views - Or "Ad that follow me"

I was initially surprised to see that the adverts displayed in some of the pages were related to products I had searched previously in some retail websites. I wondered how the ad could show the exact product I had viewed a few days ago. Sooner I noticed a small 'i' symbol in the right bottom corner which showed the message 'Would you like to learn more about why you are seeing this ad?'. I followed the link and finally disabled the ads that follow me. :-)

It was nice of criteo to provide a guide to disable the feature. Here is the link to disable the feature. to block Criteo banner via Browser Options.pdf