Tuesday, 20 September 2011

Perform a URI check in PowerShell using WebRequest


here is how to write a url checker in powershell.. enjoy[csharp]

Set-ExecutionPolicy RemoteSigned
$logpath = "C:\powershell logs\"

#build filename from parts
$outputfile = "{0}\{1:dd.yyyy.MM-hh.mm.ss}-site_response.txt" -f $logpath, $(Get-Date)

$sitelist = Get-Content C:\install\psscripts\sites.txt

Foreach($url in $sitelist) {
    $request = [net.WebRequest]::Create($url)
    $response = $request.GetResponse()
    $content = $response.ResponseUri
    $response.ResponseUri, $response.LastModified, $response.StatusCode | format-list | Out-File $outputfile -append

Thursday, 1 September 2011

Check Mail Server Using Telnet on windows command line


I had someone ask today how to check if a mail server was working. So here is how to do it using telnet from the command line.

The idea here is that you know the mailserver domain, and you know a valid email address that can send from that domain.

Open your command window and type telnet. If you get an error, open control panel, click programs, then click "turn windows features on or off"

In the box that pops up, select the telnet options. Let it install, close you command window and re-open it then type the following:

EHLO google.com 
MAIL FROM:valid@emailaddress.com 
RCPT TO: me@myaddress.com 

Subject: test message from server name 

This is a test message you will not see a response from this command. 

You should receive the mail. 

If any of the above commands produce an error, something is wrong.