Export IPv4 configuration
Documentation: Microsoft Learn
Get-NetIPAddress limited to -AddressFamily IPv4 returns every address bound to every interface.
The script
Script reader
Inspect before you run
Inspect the script below. It does not run in this browser.
Inspection only — no command has run.
Show reference output
Inspect this example’s structure
Read the command and its supplied arguments. This example requires real PowerShell or its module; this diagram does not execute it.
Get-NetIPAddress -AddressFamily IPv4 | Select-Object IPAddress,PrefixLength,InterfaceAlias,AddressState- Stage 1Get-NetIPAddress
-AddressFamily - Stage 2Select-Object
Positional values or no named parameters
How it works
Get-NetIPAddress limited to -AddressFamily IPv4 returns every address bound to every interface. Select-Object reports the address with its PrefixLength, the InterfaceAlias it belongs to, and AddressState, which tells you whether the stack currently considers the address usable.
Adapting it
Add PrefixOrigin and SuffixOrigin to the property list to separate a statically assigned address from one handed out by DHCP, since the address value alone will not tell you which it is.
If the result is unexpected
The list includes an address in the 169.254 range, or an address that should be live reports an AddressState other than Preferred.
An APIPA address means the interface requested a DHCP lease and did not receive one, so the stack self-assigned. AddressState reports the outcome of duplicate address detection, and Tentative or Duplicate means the address is configured but not usable for traffic. Both appear as ordinary rows, so a report reading only IPAddress misses the problem completely.
- Check AddressState on every row and treat anything other than Preferred as a finding.
- For an APIPA address, look at the DHCP client service and test reachability to the DHCP server or relay.
- Run Get-NetIPConfiguration for a combined view carrying the gateway and DNS servers alongside the address.
- Read PrefixOrigin to establish whether the address came from DHCP, a manual entry, or the well-known fallback.
- Test for a duplicate by pinging the address from another host while this interface is disabled.
Validate the result
Every interface meant to be in service reports a Preferred AddressState with a PrefixOrigin matching how it was configured.
Keep the check reliable
Include AddressState and PrefixOrigin in any address inventory, since the address on its own does not tell you whether it works.