views:

16

answers:

1

all,

is there any script that I can put on a scheduler to auto reset adapter only if there is a network connection failure?

I am running Windows 7

-Jeremy

A: 

Here's a Powershell script for doing this, replace n.n.n.n with your Default Gateway IP address and Name of connection with the name of your connection!

$pingtest = test-connection n.n.n.n -count 1 -quiet

if(!$pingtest)
{
 $nic = gwmi win32_networkadapter -filter "NetConnectionID='Name of connection'"
  $nic.disable()
  sleep 5
  $nic.enable()
}

Save this as filename.ps1 (for example) and create a Windows scheduled task with the following command:

Powershell.exe c:\pathtoscript\filename.ps1 -noprofile -Noninteractive

If you haven't used powershell before then start it up and run the following command to ensure your scheduled script will run:

Set-ExecutionPolicy RemoteSigned

More on this here: Powershell Execution Policy