PowerShell: Get Local IP Address
Need to check a machine's local (private) IP address - for network troubleshooting, documentation, or confirming which network it's connected to? This one-liner pulls it straight from the system, filtered down to just the useful result.
Prerequisites:
- Privileges: None
- Module: Built-in, no import needed
Quick Command:
Get-NetIPAddress -AddressFamily IPv4 | Where-Object { $_.InterfaceAlias -notlike "*Loopback*" } | Select-Object IPAddress, InterfaceAlias
Example Output:
IPAddress InterfaceAlias
--------- --------------
10.214.52.3 Ethernet
📦
Want all of them at once?
Get every free one-liner from this blog in a single downloadable bundle organized by category, each with full comment-based help. No more copy-pasting one at a time.
Get every free one-liner from this blog in a single downloadable bundle organized by category, each with full comment-based help. No more copy-pasting one at a time.
How It Works:
- Get-NetIPAddress returns every IP address configured on the system - by default this includes IPv6, loopback addresses, and multiple entries per adapter, which is far more than needed for a quick lookup.
- -AddressFamily IPv4 filters down to only IPv4 addresses, skipping the IPv6 entries entirely.
- Where-Object { $_.InterfaceAlias -notlike "*Loopback*" } excludes the loopback interface (127.0.0.1) - the internal address every machine uses to refer to itself, not a real network address.
- Select-Object IPAddress, InterfaceAlias trims the output down to just the address and which network adapter it belongs to.