Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade
The Get-NetIPAddress
cmdlet is a powerful tool in Windows PowerShell that allows users to view and manage network IP addresses on a local or remote computer. This cmdlet is part of the NetTCPIP module, which is included in Windows 8, Windows Server 2012, and later versions. It provides detailed information about the IP configuration, including IP address, interface index, address family, and more.
Examples:
Basic Usage:
To retrieve all IP addresses configured on your computer, simply open PowerShell and enter the following command:
Get-NetIPAddress
This command will list all IP addresses, including both IPv4 and IPv6, along with additional details such as the InterfaceAlias, AddressFamily, and IPAddress.
Filter by Address Family:
If you want to view only IPv4 addresses, you can filter the results using the -AddressFamily
parameter:
Get-NetIPAddress -AddressFamily IPv4
Similarly, to view only IPv6 addresses, use:
Get-NetIPAddress -AddressFamily IPv6
Filter by Interface:
To find the IP address associated with a specific network interface, use the -InterfaceAlias
parameter. For example, to get the IP address of the "Ethernet" interface, run:
Get-NetIPAddress -InterfaceAlias "Ethernet"
Remote Computer:
You can also retrieve IP addresses from a remote computer using the -CimSession
parameter. First, create a CIM session to the remote computer:
$session = New-CimSession -ComputerName "RemoteComputerName"
Then, use the session with Get-NetIPAddress
:
Get-NetIPAddress -CimSession $session
Remember to replace "RemoteComputerName" with the actual name or IP address of the remote computer.
Advanced Filtering:
For more advanced filtering, you can use the Where-Object
cmdlet. For example, to find all IP addresses with a specific prefix length, such as 24, use:
Get-NetIPAddress | Where-Object { $_.PrefixLength -eq 24 }
These examples demonstrate the flexibility of the Get-NetIPAddress
cmdlet for managing and retrieving IP address information on Windows systems.