MoonPoint Support Logo

 




Advanced Search
July
Sun Mon Tue Wed Thu Fri Sat
     
16
23 24 25
26 27 28 29 30 31  
2026
Months
JulAug Sep
Oct Nov Dec


Thu, Jul 16, 2026 6:53 pm

Querying and setting network settings with PowerShell

To determine the IP address of a Microsoft Windows system from a command-line interface (CLI) you can open a command prompt window and use the ipconfig command ipconfig /all. If you only need the IPv4 address you can pipe the output into find or findstr. Alternatively, you can use a netsh command.

C:\>ipconfig /all | find "IPv4 Address"
   IPv4 Address. . . . . . . . . . . : 192.168.0.8(Preferred)

C:\>ipconfig | findstr /C:"IPv4"
   IPv4 Address. . . . . . . . . . . : 192.168.0.8

C:\>netsh interface ip show addresses

Configuration for interface "Ethernet"
    DHCP enabled:                         Yes
    IP Address:                           192.168.0.8
    Subnet Prefix:                        192.168.0.0/24 (mask 255.255.255.0)
    Default Gateway:                      192.168.0.1
    Gateway Metric:                       0
    InterfaceMetric:                      25

Configuration for interface "Loopback Pseudo-Interface 1"
    DHCP enabled:                         No
    IP Address:                           127.0.0.1
    Subnet Prefix:                        127.0.0.0/8 (mask 255.0.0.0)
    InterfaceMetric:                      75


C:\>

You can also use a PowerShell cmdlet to view the IP address.

PS C:\> Get-NetIPAddress -AddressFamily IPv4


IPAddress         : 192.168.0.8
InterfaceIndex    : 5
InterfaceAlias    : Ethernet
AddressFamily     : IPv4
Type              : Unicast
PrefixLength      : 24
PrefixOrigin      : Dhcp
SuffixOrigin      : Dhcp
AddressState      : Preferred
ValidLifetime     : 15:58:12
PreferredLifetime : 15:58:12
SkipAsSource      : False
PolicyStore       : ActiveStore

IPAddress         : 127.0.0.1
InterfaceIndex    : 1
InterfaceAlias    : Loopback Pseudo-Interface 1
AddressFamily     : IPv4
Type              : Unicast
PrefixLength      : 8
PrefixOrigin      : WellKnown
SuffixOrigin      : WellKnown
AddressState      : Preferred
ValidLifetime     : Infinite ([TimeSpan]::MaxValue)
PreferredLifetime : Infinite ([TimeSpan]::MaxValue)
SkipAsSource      : False
PolicyStore       : ActiveStore



PS C:\>

You can get a more concise version showing the interface and address with Get-NetIPAddress -AddressFamily IPv4 |Select-Object InterfaceAlias, IPAddress.

PS C:\> Get-NetIPAddress -AddressFamily IPv4 | Select-Object InterfaceAlias, IPAddress

InterfaceAlias              IPAddress
--------------              ---------
Ethernet                    192.168.0.8
Loopback Pseudo-Interface 1 127.0.0.1


PS C:\>

[ More Info ]

[/os/windows/PowerShell] permanent link

Valid HTML 4.01 Transitional

Privacy Policy   Contact

Blosxom logo