Get and set IP addresses with PowerShell

Oct 6th 2026
By Andrew Davidson
1 min read

In my old school ways, getting the IP address of the local Windows machine was easy:

bash
1
ipconfig

Now we have a more modern shell we can use that to see what addresses are currently assigned to a Windows machine. We can query the network adapter information directly from PowerShell.

powershell
1
Get-NetIPAddress

This gives you the core IP details for each adapter, but it is a little dense, so formatting the output into a table makes it much easier to read.

powershell
1
2
Get-NetIPAddress |
    Format-Table InterfaceAlias, InterfaceIndex, IPAddress, AddressFamily

If a device is not receiving a DHCP lease, Windows often falls back to an Automatic Private IP Address in the 169.254.0.0/16 range. That is a useful clue when you are troubleshooting connectivity issues.

powershell
1
2
3
4
Get-NetIPAddress |
    Where IPAddress -like "169.*" |
    Where AddressFamily -like IPv4 |
    Format-Table InterfaceAlias, InterfaceIndex, IPAddress, AddressFamily

When you need to assign a static address manually, New-NetIPAddress is the command to use. This example sets a typical IPv4 configuration with a gateway and a /24 subnet mask.

powershell
1
New-NetIPAddress -IPAddress 192.168.1.16 -PrefixLength 24 -DefaultGateway 192.168.1.1 -Confirm:$false
Last updated on 2026-10-06