PowerTip: Use PowerShell to Configure IP Address in Windows Server 2012 R2

PowerTip: Use PowerShell to Configure IP Address in Windows Server 2012 R2

  • Comments 1
  • Likes

Summary: Use the new cmdlets in Windows Server 2012 R2 to set up an IP address on a computer with one network adapter.

Hey, Scripting Guy! Question How can I use Windows PowerShell to configure an IP address in Windows Server 2012 R2?

Hey, Scripting Guy! Answer Use the Get-NetAdapter and Add-NewIPAddress cmdlets together.

   For the IP address of 10.0.0.5, with a gateway of 10.0.0.1, and 24 bits for the subnet mask (255.255.255.0):

$IPAddress=”10.0.0.5”

$Gateway=”10.0.0.1”

$Prefix=24

Get-NetAdapter | NEW-NetIPAddress -IPAddress $IPAddress -Defaultgateway $Gateway -Prefixlength $Prefix

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • In the first answer line it says Add-NewIPAddress but that should be New-NetIPAddress as in the example.