Skip to content

PowerShell Network Configuration

How to inspect and manage network adapters, IP configurations, and DNS settings in PowerShell using Get-NetAdapter, Get-NetIPConfiguration, and related cmdlets for structured network diagnostics.

Viewing and understanding a machine's network configuration is a routine sysadmin task. Network configuration management in PowerShell centers on the NetAdapter and NetTCPIP modules, replacing the text output of ipconfig.exe with structured, filterable objects through cmdlets like Get-NetAdapter and Get-NetIPConfiguration. These expose properties such as MAC addresses, link speeds, IPv4/IPv6 addresses, default gateways, and DNS servers as queryable objects.

Inspecting Network Hardware with Get-NetAdapter

The Get-NetAdapter cmdlet retrieves physical, virtual, and tunnel network adapters installed on the host. It provides Layer 2 interface details, hardware operational status, link speed, and MAC addresses.

Consolepowershell
Get-NetAdapter
Outputplaintext
Name                      InterfaceDescription                    ifIndex Status       MacAddress             LinkSpeed
----                      --------------------                    ------- ------       ----------             ---------
Bluetooth Network Conn... Bluetooth Device (Personal Area Netw...      15 Disconnected B8-08-CF-A9-4F-1A         3 Mbps
Ethernet0                 Intel(R) 82574L Gigabit Network Conn...       6 Up           00-0C-29-A9-22-75         1 Gbps

where:

  • Status is the adapter's connection state: Up, Disconnected, or Disabled.
  • LinkSpeed is the negotiated speed of the connection.

Filtering Adapters by Status

get-adapters-demo.ps1powershell
Get-NetAdapter | Where-Object -Property Status -EQ "Up" | 
    Select-Object -Property Name, InterfaceDescription, Status, MacAddress, LinkSpeed

where:

  • Get-NetAdapter queries the MSFT_NetAdapter CIM class for network interface hardware.
  • Where-Object filters for adapters with an operational Status of Up.
  • MacAddress is the media access control (hardware) physical address of the network interface.
  • LinkSpeed is the current negotiated bandwidth (e.g., 1 Gbps, 100 Mbps).
Consolepowershell
./get-adapters-demo.ps1
Outputplaintext
Name                 : Ethernet0
InterfaceDescription : Intel(R) 82574L Gigabit Network Connection
Status               : Up
MacAddress           : 00-0C-29-A9-22-75
LinkSpeed            : 1 Gbps

Viewing Extended Adapter Properties

Consolepowershell
Get-NetAdapter -Name "Ethernet" | Select-Object *
Outputplaintext
Name                    : Ethernet
InterfaceDescription    : Intel(R) Ethernet Connection
MacAddress              : 00-1A-2B-3C-4D-5E
LinkSpeed               : 1 Gbps
MediaType               : 802.3
DriverVersion           : 12.19.0.0
...

Retrieving Configuration with Get-NetIPConfiguration

The Get-NetIPConfiguration cmdlet (aliased as gip) serves as the primary object-based equivalent to ipconfig. It consolidates IP addresses, default gateways, interface aliases, and DNS servers into a single formatted object representation, returning a per-adapter summary of IP settings.

Consolepowershell
Get-NetIPConfiguration
Outputplaintext
InterfaceAlias       : Ethernet0
InterfaceIndex       : 6
InterfaceDescription : Intel(R) 82574L Gigabit Network Connection
NetProfile.Name      : Network 2
IPv6Address          : fd00::d502:407b:2a34:1361
IPv4Address          : 192.168.178.33
IPv6DefaultGateway   :
IPv4DefaultGateway   : 192.168.178.1
DNSServer            : fd00::e228:6dff:fea5:f317
                       fd00::e228:6dff:fea5:f317
                       192.168.178.1

InterfaceAlias       : Bluetooth Network Connection
InterfaceIndex       : 15
InterfaceDescription : Bluetooth Device (Personal Area Network)
NetAdapter.Status    : Disconnected

where:

  • Get-NetIPConfiguration combines network details from multiple underlying network classes (NetIPAddress, NetRoute, and DnsClientServerAddress).
  • -InterfaceAlias restricts the query to a specific network interface name.

Viewing a Specific Adapter's Configuration

Consolepowershell
Get-NetIPConfiguration -InterfaceAlias "Ethernet0"

where -InterfaceAlias is the friendly name of the network adapter, as shown in Get-NetAdapter.

Outputplaintext
InterfaceAlias       : Ethernet0
InterfaceIndex       : 6
InterfaceDescription : Intel(R) 82574L Gigabit Network Connection
NetProfile.Name      : Network 2
IPv6Address          : fd00::d502:407b:2a34:1361
IPv4Address          : 192.168.178.33
IPv6DefaultGateway   :
IPv4DefaultGateway   : 192.168.178.1
DNSServer            : fd00::e228:6dff:fea5:f317
                       fd00::e228:6dff:fea5:f317
                       192.168.178.1

Getting Detailed Output with -Detailed

Consolepowershell
Get-NetIPConfiguration -InterfaceAlias "Ethernet" -Detailed

where -Detailed expands the output to include DNS suffix, NetBIOS settings, and additional adapter metadata, closer to the verbosity of ipconfig /all.

ipconfig Equivalent Commands

Legacy ipconfig flags produce plain text output, requiring complex parsing to extract configuration data. PowerShell and the DnsClient module provide dedicated cmdlets that output structured objects for each legacy operation:

ipconfig Command PowerShell Equivalent Module Output Type
ipconfig Get-NetIPConfiguration NetTCPIP Object
ipconfig /all Get-NetIPConfiguration -Detailed NetTCPIP Object
ipconfig /release Remove-NetIPAddress / Disable-NetAdapter NetTCPIP / NetAdapter Object
ipconfig /renew Enable-NetAdapter (or a DHCP-specific renew) NetAdapter / CimCmdlets Object
ipconfig /flushdns Clear-DnsClientCache DnsClient None (Void)
ipconfig /displaydns Get-DnsClientCache DnsClient Object

Flushing the DNS Cache

Consolepowershell
Clear-DnsClientCache

Viewing the DNS Cache

Consolepowershell
Get-DnsClientCache | Select-Object Entry, Data
Outputplaintext
Entry                                 Data
-----                                 ----
one.one.one.one                       2606:4700:4700::1001
one.one.one.one                       2606:4700:4700::1111
one.one.one.one                       1.0.0.1
one.one.one.one                       1.1.1.1
array803.prod.do.dsp.mp.microsoft.com 72.154.7.96
array808.prod.do.dsp.mp.microsoft.com 72.154.7.101
array802.prod.do.dsp.mp.microsoft.com 72.154.7.17

Querying Specific Cache Entries

dns-cache-ops.ps1powershell
Clear-DnsClientCache

Get-DnsClientCache -Entry "github.com" -ErrorAction SilentlyContinue | 
    Select-Object -Property Entry, Type, Status, TimeToLive, Data

where:

  • Clear-DnsClientCache flushes and purges all entries in the local DNS resolver cache.
  • Get-DnsClientCache retrieves records stored in the client DNS cache.
  • -Entry filters the cache for a specific domain name.
  • TimeToLive is the number of seconds before the DNS record expires from cache.
Consolepowershell
./dns-cache-ops.ps1
Outputplaintext
Entry      Type Status TimeToLive Data
-----      ---- ------ ---------- ----
github.com    A Success        240 140.82.112.4

Practical Usage

Full Network Configuration Report

A useful admin script combines adapter status and IP configuration into a single readable report, replacing the need to manually cross-reference multiple ipconfig sections.

network-config-report.ps1powershell
$adapters = Get-NetAdapter | Where-Object { $_.Status -eq "Up" }

foreach ($adapter in $adapters) {
    $config = Get-NetIPConfiguration -InterfaceAlias $adapter.Name

    [PSCustomObject]@{
        Adapter    = $adapter.Name
        LinkSpeed  = $adapter.LinkSpeed
        IPAddress  = $config.IPv4Address.IPAddress
        Gateway    = $config.IPv4DefaultGateway.NextHop
        DNSServers = ($config.DNSServer.ServerAddresses -join ", ")
    }
}

where:

  • Where-Object { $_.Status -eq "Up" } filters to only active adapters.
  • [PSCustomObject] builds a clean, custom-formatted result combining data from both cmdlets.
  • -join ", " combines multiple DNS server addresses into a single readable string.
Consolepowershell
./network-config-report.ps1
Outputplaintext
Adapter    : Ethernet0
LinkSpeed  : 1 Gbps
IPAddress  : 192.168.178.33
Gateway    : 192.168.178.1
DNSServers : fd00::e228:6dff:fea5:f317, fd00::e228:6dff:fea5:f317, 192.168.178.1

Client Network Troubleshooting Pipeline

During client network connectivity outages, administrators frequently need to collect interface health, flush cached lookups, verify gateway assignment, and test DNS resolution in a single automated step.

diagnose-client-network.ps1powershell
$adapterName = "Ethernet0"

$adapter = Get-NetAdapter -Name $adapterName
if ($adapter.Status -ne "Up") {
    Write-Warning "Adapter '$adapterName' is disconnected or disabled!"
    return
}

Clear-DnsClientCache
Write-Output "DNS Client Cache successfully cleared."

$ipConfig = Get-NetIPConfiguration -InterfaceAlias $adapterName

[PSCustomObject]@{
    AdapterName   = $adapter.Name
    Status        = $adapter.Status
    LinkSpeed     = $adapter.LinkSpeed
    IPv4Address   = $ipConfig.IPv4Address.IPAddress
    Gateway       = $ipConfig.IPv4DefaultGateway.NextHop
    PrimaryDNS    = ($ipConfig.DNSServer.ServerAddresses)[0]
    GatewayPing   = (Test-Connection -TargetName $ipConfig.IPv4DefaultGateway.NextHop -Count 1 -Quiet)
}

where:

  • $adapter.Status validates the physical link state before running queries.
  • $ipConfig.IPv4DefaultGateway.NextHop retrieves the IP address string of the configured gateway router.
  • Test-Connection -Quiet returns $true or $false to verify gateway reachability.
Consolepowershell
./diagnose-client-network.ps1
Outputplaintext
DNS Client Cache successfully cleared.

AdapterName : Ethernet0
Status      : Up
LinkSpeed   : 1 Gbps
IPv4Address : 192.168.178.33
Gateway     : 192.168.178.1
PrimaryDNS  : fd00::e228:6dff:fea5:f317
GatewayPing : True
Navigation