Friday, July 29, 2011

Low-budget warm-up for Web application or how to automate ping a Website

In different IT scenarios there’s a need to access a Website just to check if it is available or even to ignite it’s start.

There are some automation tools for this purpose: I’ve seen even a download from Microsoft Website for warm-up of Microsoft CRM Websites – but do not recall where.

The quick and cheap alternative is to use PowerShell script for this purpose and bind it to a scheduled task.

This is the script – quite self-explanatory

    #check and create an eventlog source to report results of website probing
$eventLogSource =
"ProbeWeb";
if (![system.diagnostics.eventlog]::SourceExists($eventLogSource))
{
new-eventlog -logname Application -source $eventLogSource
}
#create webclient
$webClient = new-object System.Net.WebClient
$output = "";
$webSite = “http://winmike.blogspot.com”;
$startTime = get-date
#probe thewebsite
$output = $webClient.DownloadString($webSite)
$endTime = get-date
#test website response for desired character sequence
if ($output -like "*Mike*")
{
$message = $webSite + " succeeded " + $startTime.DateTime + " " + ($endTime -$startTime).TotalSeconds +
" seconds"
}
else
{
$message = $webSite + " failed " + $startTime.DateTime + " " + ($endTime - $startTime).TotalSeconds +
" seconds"
}
#record the results
write-eventlog -logname Application -source $eventLogSource -eventID 42
-message $message
Save this script in a file on the disk (for exampe, in c:\scripts\probeweb.ps1).
Start the script from powershell
x10sctmp0
and you will see the output in the eventlog - smth like that:
x10sctmp
Well, now bind it to a scheduled task. Open the Task Scheduler Library (via computer management) and select “Create Basic Task…”:
x10sctmp1
Enter task name and description, then select time period to repeat the task:
x10sctmp2 x10sctmp3
Select “start a program! as a task action:
x10sctmp4
Enter program name as follows
c:\windows\system32\WindowsPowerShell\v1.0\powershell.exe
(check the %SystemRoot% – your drive letter and path may vary)
and
c:\scripts\probewe.ps1
as argument (or alternate path to your script):
x10sctmp5
Review summary of the task:
x10sctmp6
…and confirm the task. You will see the task in the list of your task library:
x10sctmp7
Open the task properties and assure “Run whether user is logged on or not” is selected and the correct user account is used as execution context.
x10sctmp9
Confirm the password if requested.
Run newly created task to make sure it works:
x10sctmp10
Analyze the results
x10sctmp11
…and enjoy!

Monday, July 11, 2011

CD/DVD/Data Recovery source (hints and utilities)

Neither an advertisement, nor announcement. No my personal warranty. Only recommendation.

I was looking for help to rescue some data on my older CDs and HDDs. Found here: RLAB.

x10sctmp

You’ll find there many useful data recovery utilities – and numerous freeware among them.

Used with success:

R.Viewer – creates list of the disk files in different formats. This utility is very useful to get a snapshot of the file list on your drive: for example, to compare it with an earlier backup set or for other purposes. Supports CSV, HTML, XML formats – the result can be used in Microsoft Excel for filtering,sorting and further processing.

CHKParser32 – supports recovery of the damaged data, found after running chkdsk utility. Check Disk (chkdsk) utility collects “orphaned” or other way damaged files in .chk files. CHKParser32 helps to join them into meaningful data files (pictures, texts etc.).