Whenever your computer is connected to a network or the Internet, your device will have two IP addresses—the public IP address and the private IP address.

All devices on the Internet use your public IP for communication, whereas the private IP is for your local network only. In fact, when most utilize the term “IP address,” they actually refer to a private IP address.

you may find out your computer’s private and public IP through PowerShell in different ways. I will also show how to assign the IP address to a variable, which is useful if you are writing a PowerShell script.

get-net-ip-address-where-object

How to Get Private IP Address in PowerShell?

you may use various Net TCP/IP-specific and device management-related cmdlets on PowerShell to get the private IP address. These cmdlets check your network and network adapter configurations, including this data.

Also, while all these cmdlets allow you toget the IP address, they show other parameters as well. Since the type of parameters differs between the cmdlets, you might prefer one over the other depending on your situation.

Using Get-NetIPAddress

The standard way to display the IP address in PowerShell is by using theGet-NetIPAddresscmdlet, which shows the IP address configuration.

get-net-ip-address-where-object-ipaddress

This cmdlet lists the IP configuration of all physical and virtual networks on your system. So, you need to combine it with an additional cmdlet to narrow down the result to the current network.

Using Get-NetIPConfiguration

Another way you may determine the current IP address is by checking the current network configuration viaGet-NetIPConfiguration.

As with the above case,Get-NetIPConfigurationalso lists out all network configurations. So, it’s better to use theWhere-Objectcmdlet to list the current network details only.

get-net-ip-address-where-object-ipaddress-variable

IPConfigis the Command Prompt equivalent ofGet-NetIPConfiguration. Since PowerShell also allows you to use Command Prompt commands, you canuse IPConfigas well.

Using Test-NetConnection

Test-NetConnectionis the latest replacement for ping and traceroute functions in PowerShell. This cmdlet also displays the IP address of your computer while performing a ping test.

get-netipconfiguration-where-object

get-netipconfiguration-where-object-ipv4address-ipaddress

get-netipconfiguration-where-object-ipv4address-ipaddress-variable

ipconfig-ipv4-address

ipconfig-findstr-and-variable