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";
new-eventlog -logname Application -source $eventLogSource
$webClient = new-object System.Net.WebClient
$output = "";
$webSite = “http://winmike.blogspot.com”;
$startTime = get-date
$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"
$message = $webSite + " failed " + $startTime.DateTime + " " + ($endTime - $startTime).TotalSeconds + " seconds"
#record the results
write-eventlog -logname Application -source $eventLogSource -eventID 42
Save this script in a file on the disk (for exampe, in c:\scripts\probeweb.ps1).
Start the script from powershell
and you will see the output in the eventlog - smth like that:
Well, now bind it to a scheduled task. Open the Task Scheduler Library (via computer management) and select “Create Basic Task…”:
Enter task name and description, then select time period to repeat the task:
Select “start a program! as a task action:
Enter program name as follows
(check the %SystemRoot% – your drive letter and path may vary)
as argument (or alternate path to your script):
Review summary of the task:
…and confirm the task. You will see the task in the list of your task library:
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.
Confirm the password if requested.
Run newly created task to make sure it works:
Analyze the results