IP addresses are important for many reasons, including security. You can change your IP address using PowerShell. Here’s how:

  1. Open a PowerShell window and type “ipconfig” to get the IP address of your computer.
  2. Type “netstat -a” to see all the network connections on your computer.
  3. Type “ping -c 3 192.168.1.1” to test whether your computer is connected to the internet and able to ping 192.168.1.1 (the IP address of your computer). If not, you may need to update your router or firewall software or add a public IP address for your computer so that internet access works correctly again (see below for more information).
  4. To change your IP address, type “ipconfig /all” and press ENTER (or use the arrow keys on your keyboard). The new IP address will be displayed in a text editor like Notepad or Wordpad (depending on which program you used to get the original IP address).

We have already shown you how you can change your IP address from the command prompt, which required long netsh commands, now we are doing the same thing in PowerShell, without the complexity.

Note: The following commands are new in PowerShell v3 and therefore require Windows 8, they also require an administrative command prompt.

Editors Note: This article is probably for our more geeky audience and requires some basic knowledge of IP Addressing and CIDR notation

Changing Your IP Address

We have seen people pulling out their hair trying to change their IP addresses using cryptic WMI classes in older versions of PowerShell, but that changed with PowerShell v3, there is now a NetTCPIP module that brings most of the functionality to native PowerShell. While a bit confusing at first, mostly due to the lack of documentation at the moment, it starts to make sense once the geeks shows you how its done.

Changing an IP Address can be done using the New-NetIPAddress cmdlet, it has a lot of parameters, some of which, are not even documented in Get-Help. So here it is:

This assumes the following:

The name of the interface you want to change the IP address for is Wired Ethernet Connection You want to statically assign an IP address of 192. 168. 0. 1 You want to set a subnet mask of 255. 255. 255. 0 (which is /24 in CIDR notation) You want to set a default gateway of 192. 168. 0. 254

You would obviously switch the settings out for some that match the addressing criteria for your network.

Setting Your DNS Information

Now here comes another tricky part, it turns out that there is a whole separate module called DNSClient that you have to use to manipulate your DNS Settings. To change your DNS Server you would use:

This assumes that you want to set the primary DNS server for Wired Ethernet Connection to 192.168.0.1 and the secondary DNS server to 192.168.0.2. That’s all there is to it.