function to_direct () {
     $ NICs = Get-WMIObject Win32_NetworkAdapterConfiguration |  ? {$ _. IPEnabled -eq “TRUE”}
     Foreach ($ NIC in $ NICs) {
       $ NIC.EnableStatic ("64.38.232.180", “255.255.255.0")
       $ NIC.SetGateways ("64.38.232.180")
       $ DNSServers = “216.7.89.63", ”64.38.232.180]"
       $ NIC.SetDNSServerSearchOrder ($ DNSServers)
       $ NIC.SetDynamicDNSRegistration (”FALSE”)
     }
 }
 function to_router () {
   $ NICs = Get-WMIObject Win32_NetworkAdapterConfiguration |  ? {$ _. IPEnabled -eq “TRUE”}
	 Foreach ($ NIC in $ NICs) {
  		 $ NIC.EnableStatic ("192.168.1.3", “255.255.255.0")
         $ NIC.SetGateways ("192.168.1.1")
         $ DNSServers = “192.168.1.1", "192.168.1.2"
         $ NIC.SetDNSServerSearchOrder ($ DNSServers)
         $ NIC.SetDynamicDNSRegistration (”FALSE”)
     }
 }
Source: https://habr.com/ru/post/59712/
All Articles