locked
How to change default gateway on clients using powershell RRS feed

  • Question

  • Wanted to know was it possible to change the default gateway on all my client machines using power shell ?
    Wednesday, May 11, 2016 4:29 PM

Answers

  • Did you ask a search engine?

    Short answer - use DHCP to set this.

    Long answer - Yes, but you should be using DHCP to set this.


    EDIT: Make sure you see Xecros's post as well.

    Wednesday, May 11, 2016 4:35 PM
  • if your using DHCP, change it in the scope, and then you can use a powershell script to force the client to renew it's Lease right away, thus getting the new gateway.

    If your not using DHCP, yes, it's possible.

    Wednesday, May 11, 2016 5:39 PM
  • Forcing the Lease to renew right away is important, especially if you have a long lease duration.  For example, if you have a 1 week Lease set in DHCP, it could take clients, up to 3 1/2 days before it will receive the new gateway information.

    A 30 day lease, and your clients will wait 2 weeks before getting the new gateway.

    Wednesday, May 11, 2016 6:12 PM

All replies

  • Did you ask a search engine?

    Short answer - use DHCP to set this.

    Long answer - Yes, but you should be using DHCP to set this.


    EDIT: Make sure you see Xecros's post as well.

    Wednesday, May 11, 2016 4:35 PM
  • if your using DHCP, change it in the scope, and then you can use a powershell script to force the client to renew it's Lease right away, thus getting the new gateway.

    If your not using DHCP, yes, it's possible.

    Wednesday, May 11, 2016 5:39 PM
  • Forcing the Lease to renew right away is important, especially if you have a long lease duration.  For example, if you have a 1 week Lease set in DHCP, it could take clients, up to 3 1/2 days before it will receive the new gateway information.

    A 30 day lease, and your clients will wait 2 weeks before getting the new gateway.

    Wednesday, May 11, 2016 6:12 PM
  • Hi,

    Using WMI  “Win32_NetworkAdapterConfiguration

    Details you may reference below link :
    http://www.happysysadm.com/2012/03/remotely-changing-default-gateway.html 

    Best Regards,
    Eve Wang

    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.

    Sunday, May 15, 2016 1:04 PM