Knightsman
asked on
Auto restart computer if ping fails
We have a remote server (1hr drive) for a surveillance system. For some reason it randomly goes offline. The only fix at the moment is to restart. No error logs at all. Router works because we can bring up the cameras behind it. We updated the drivers but its not the best thing to drive out there each time and hope it works better.
I found this batch, but I get the error: "IP" was unexpected at this time??
So i'm looking for a bat file or something, that I can schedule to run every 10 minutes. (i know that's frequent, but I don't want the cameras not recording for longer than that.)
Any help is appreciated.
I found this batch, but I get the error: "IP" was unexpected at this time??
If (!(Test-Connection 192.168.20.199 -quiet)) {
#Write-Host "Not connected"
Restart-Computer
}
Else {
#Write-Host "Connected"
}
So i'm looking for a bat file or something, that I can schedule to run every 10 minutes. (i know that's frequent, but I don't want the cameras not recording for longer than that.)
Any help is appreciated.
Does the computer lose IP connection? If so, you should verify that the Ethernet Card isn't going to sleep. Some NICs have this nuisance property. Go to Device Manager. Right Click on Network Card. Select Properties, Click on Power Management Tab, Uncheck the "Allow the computer to turn off this device to save power" Option
To answer your original question, I believe that the Test-Connection cmdlet is looking for a computer name, not an IP address.
Test-Connection <computername>
http://technet.microsoft.com/en-us/library/hh849808.aspx
Test-Connection <computername>
http://technet.microsoft.com/en-us/library/hh849808.aspx
ASKER
Thanks for that, the first check box was checked. I completely forgot to look there, i assumed when power mode was set to maximum it didn't set those.
I don't have another computer name the server can search for. I guess I could use one of the cameras. But if a camera goes down, that would then cause a big problem.
I'd prefer for it to ping a DNS server, maybe even two. then restart if ping fails
I don't have another computer name the server can search for. I guess I could use one of the cameras. But if a camera goes down, that would then cause a big problem.
I'd prefer for it to ping a DNS server, maybe even two. then restart if ping fails
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Other possible issues or causes could be a bad port on the switch, router the server is connected to, or the cable itself