locked
[Powershell] VPN s2s interface connect/disconnect RRS feed

  • Question

  • Hello. There is a remote server with RRAS role installed. Server connects to main office network via s2s demand-dial VPN.

    I'm trying to write a script to reconnect it when some conditions reached. I use Connect/Disconnect VpnS2SInterface cmdlets for this. But Connect cmdlet works only when connection is in "allowed" state, and Disconnect cmdlet works when connection in "disallowed" state.

    Which cmdlet should i use to modify state of connection?

    Thanks.

    Wednesday, December 17, 2014 9:19 PM

Answers

  • Found this solution, by the way.

    Invoke-Expression "netsh routing demanddial set interface name=vpns2s admin=disabled"
    Invoke-Expression "netsh routing demanddial set interface name=vpns2s connstate=disconnect"
    Invoke-Expression "netsh routing demanddial set interface name=vpns2s admin=enabled"
    Can be used without powershell as well.



    • Marked as answer by pawellrus Sunday, January 25, 2015 5:39 PM
    • Edited by pawellrus Sunday, January 25, 2015 5:41 PM
    Sunday, January 25, 2015 5:39 PM

All replies

  • You fail to say what conditions you are looking for.

    Why not just option to reconnect automatically.


    ¯\_(ツ)_/¯

    Wednesday, December 17, 2014 10:48 PM
  • The condition is ping loss to some network address.
    Thursday, December 18, 2014 4:06 AM
  • The condition is ping loss to some network address.

    Then auto-reconnect (redial) is what you want.


    ¯\_(ツ)_/¯

    Thursday, December 18, 2014 7:24 AM
  • The problem is that sometimes i have a situation when connection is established, but network resources are not available. After reconnect everything is working fine.
    Thursday, December 18, 2014 8:03 AM
  • Found this solution, by the way.

    Invoke-Expression "netsh routing demanddial set interface name=vpns2s admin=disabled"
    Invoke-Expression "netsh routing demanddial set interface name=vpns2s connstate=disconnect"
    Invoke-Expression "netsh routing demanddial set interface name=vpns2s admin=enabled"
    Can be used without powershell as well.



    • Marked as answer by pawellrus Sunday, January 25, 2015 5:39 PM
    • Edited by pawellrus Sunday, January 25, 2015 5:41 PM
    Sunday, January 25, 2015 5:39 PM