Get and set IP addresses with PowerShell
In my old school ways, getting the IP address of the local Windows machine was easy:
| |
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.
| |
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.
| |
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.
| |
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.
| |