How To Set Static IP Using PowerShell in Windows

In the previous post, we have explained a step by step guide to configure static IP using GUI and CLI methods. Setting static IP address and other TCP/IP settings using GUI is fairly easy. However, setting IP address using CLI method is a little bit complicated. There are tools that you can use to set or configure static IP in Windows systems: Using the netsh CMD command and NewNetIPAddress PowerShell cmdlet. Here, we are going to explain how to set static IP using PowerShell.

Setting Static IP Using PowerShell

Before setting and configuring static IP using Windows PowerShell, let’s understand the New-NetIPAddress cmdlet and its syntax.

New-NetIPAddress –InterfaceIndex “Interface Index Number” –IPAddress "Your IPv4 Address" –PrefixLength "Network ID" -DefaultGateway "Your Default Gateway"

To configure or set static IP using PowerShell, you need to perform the following steps:

  1. First of all, execute the Get-NetAdpater PowerShell cmdlet to view all the network adapters on your Windows system.

    View Current IP address using Get-NetIPAddress PowerShell cmdletNote down the Index Number of the network adapter for which you want to set Static IP. For example, we want to set static IP on the Ethernet 2 network adapter. As shown in the preceding figure, its index number is 32.

  2. For example, let’s see how to set following TCP/IP settings using PowerShell.
    • IP Address:
    • Subnet Mask:
    • Default Gateway:
    • Interface Name: Ethernet 2
    • Interface Index Number: 32
  3. To set preceding TCP/IP settings, execute the following PowerShell cmdlet:
    New-NetIPAddress –InterfaceIndex “32” –IPAddress “” –PrefixLength 24 -DefaultGateway

    Configure Static IP using PowerShell cmdlet

  4. In the preceding figure, you can see the TCP/IP settings have been configured using the New-NetIPAddress PowerShell cmdlet.

Removing IP Address Using Windows PowerShell

  • If you have done something wrong and decide to remove a specific IP address, use the following PowerShell cmdlet.
C\>Remove-NetIPAddress -IPAddress <IP Address that you want to remove>
  • For example, use the following cmdlet to remove previously configure static IP address.
C\>Remove-NetIPAddress -IPAddress

Remove-NetIPAddress Syntax Example

For more information about managing TCP/IP settings on Windows using PowerShell, visit the Microsoft’s official TechNet library. The following are some of the important cmdlet links that you might like.

Here, we have explained how to configure or set static IP using PowerShell in Windows systems such as Windows 8/10 and Windows Server 2012/2016. Do share the article to your friend circle.

Posted in Windows 10, Windows Server 2016 Tagged with: , ,