Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do I change another computer's network settings from Powershell and/or .NET?

Target computers in question are in the same domain as mine and I am an administrator on all machines involved.

Any simple answers?

share|improve this question
What type of control do You need? What do You mean by remote? Do You only need to change networks settings for script or to trigger script or trigger withs some parameters from remote client? First case should be easy, but for true remote control You need to write/use some server code. For example You can do this using sockets, or use http server. – Maciek Sawicki Feb 1 '10 at 15:47
up vote 2 down vote accepted

I found the answer.

We can create a WMI object in PowerShell representing the network settings for IP-enabled adapters on a remote server.

$a = Get-WMIObject Win32_NetworkAdapterConfiguration -ComputerName MyServer -Filter IPEnabled=TRUE

This object will most likely be an array of network adapter objects of which only one is needed. So we want to point to that one, probably the first object in the array:

$a = $a[0]

Now we can configure whatever we want, including the IP address.

$a.EnableStatic("", "")

The one thing I couldn't figure out is how to determine the netmask!

share|improve this answer

Two useful links:

share|improve this answer
The first is simply the Powershell download page, the second describes a solution to a different problem (remoting instead of remote network configuration). – Andrew J. Brehm Feb 2 '10 at 12:29
The first one is not only about PowerShell: "WinRM 2.0 WinRM is the Microsoft implementation of WS-Management Protocol, a standard Simple Object Access Protocol (SOAP)–based, firewall-friendly protocol that allows for hardware and operating systems from different vendors to interoperate. The WS-Management Protocol specification provides a common way for systems to access and exchange management information across an IT infrastructure." And If You have remote access to machine you can do also remote network configuration. – Maciek Sawicki Feb 2 '10 at 14:51
PowerShell 2.0 comes with WinRM 2.0. And that's the download page for it. It doesn't help at all with my question. Also, to activate remote access for PowerShell I'd have to log on via RDC and activate it. Sort of defeats the purpose of using PowerShell to get and set the network configureation in the first place. – Andrew J. Brehm Feb 2 '10 at 15:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .