Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
1  
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

2 Answers 2

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("192.168.42.2", "255.255.255.0")

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

share|improve this answer

Two useful links:

  1. http://support.microsoft.com/kb/968929
  2. http://geekswithblogs.net/Lance/archive/2009/01/09/powershell-server-v2-vs-powershell-v2-remoting-via-winrm.aspx
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.