Set Ip Server 2012 PowerShell

To set a static IP address

  1. In Windows PowerShell, run Get-NetIPInterface.
  2. Make a note of the number shown in the IfIndex column of the output for your IP interface or the InterfaceDescription string. If your computer has more than one network adapter, make a note of the number or string corresponding to the interface for which you wish to set a static IP address.
  3. In Windows PowerShell, run New-NetIPAddress –InterfaceIndex 12 –IPAddress -192.0.2.2 –PrefixLength 24 –DefaultGateway -192.0.2.1

    Where:

    InterfaceIndex is the value of IfIndex from Step 2 (in this example, 12)

    IPAddress is the static IP address you intend to set (in this example, 192.0.2.2)

    PrefixLength is the prefix length (another form of subnet mask) for the IP address you intend to set (in this example, 24)

    DefaultGateway is the default gateway (in this example, 192.0.2.1)

  4. In Windows PowerShell, run Set-DNSClientServerAddress –InterfaceIndex 12 -ServerAddresses 192.0.2.4

    Where:

    InterfaceIndex is the value of IfIndex from Step 2

    ServerAddresses is the IP address of your DNS server

  5. To add multiple DNS servers, run Set-DNSClientServerAddress –InterfaceIndex 12 -ServerAddresses 192.0.2.4,192.0.2.5

    Where in this example, 192.0.2.4, 192.0.2.5 are both IP addresses of DNS servers

If you need to switch to using DHCP, use the Windows PowerShell command Set-DnsClientServerAddress –InterfaceIndex 12 –ResetServerAddresses.

Found on technet

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.