Link to home
Start Free TrialLog in
Avatar of David Sankovsky
David SankovskyFlag for Israel

asked on

Proactive Monitoring using PowerShell Script

Hi Guys,
I have a certain application that runs on port 3000.
I'm looking for a way to make a powershell script that I can later turn into a service that will do the following:
It will telnet locahist on port 3000,
If it's open, the script will rest for 3 minutes, otherwise it will call a batch file that will restart the application.

I know how to make the script into the service I'm not sure how to catch the output of the telnet... is it at all possible?
ASKER CERTIFIED SOLUTION
Avatar of Shabarinath TR
Shabarinath TR
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of David Sankovsky

ASKER

Hi.. you beat my by like.. 2 minutes.. I was about to close the ticket myself...
Funnily enough we both made the very same thing...

While (1)
{
    $result = Test-NetConnection -Computername localhost -Port 3000
    if ($result.TcpTestSucceeded -like "True")
    {
        Start-Sleep -s 180
    }
    else
    {
        #call batch file
        Start-Sleep -s 60
    }
}

Open in new window


Thanks for the help anyway :)
Great Script.
Works like a charm