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.
Get-NetAdapterName 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 Gbpswhere:
Statusis the adapter's connection state:Up,Disconnected, orDisabled.LinkSpeedis the negotiated speed of the connection.
Filtering Adapters by Status
Get-NetAdapter | Where-Object -Property Status -EQ "Up" |
Select-Object -Property Name, InterfaceDescription, Status, MacAddress, LinkSpeedwhere:
Get-NetAdapterqueries theMSFT_NetAdapterCIM class for network interface hardware.Where-Objectfilters for adapters with an operationalStatusofUp.MacAddressis the media access control (hardware) physical address of the network interface.LinkSpeedis the current negotiated bandwidth (e.g.,1 Gbps,100 Mbps).
./get-adapters-demo.ps1Name : Ethernet0
InterfaceDescription : Intel(R) 82574L Gigabit Network Connection
Status : Up
MacAddress : 00-0C-29-A9-22-75
LinkSpeed : 1 GbpsViewing Extended Adapter Properties
Get-NetAdapter -Name "Ethernet" | Select-Object *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.
Get-NetIPConfigurationInterfaceAlias : 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 : Disconnectedwhere:
Get-NetIPConfigurationcombines network details from multiple underlying network classes (NetIPAddress,NetRoute, andDnsClientServerAddress).-InterfaceAliasrestricts the query to a specific network interface name.
Viewing a Specific Adapter's Configuration
Get-NetIPConfiguration -InterfaceAlias "Ethernet0"where -InterfaceAlias is the friendly name of the network adapter, as shown in Get-NetAdapter.
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.1Getting Detailed Output with -Detailed
Get-NetIPConfiguration -InterfaceAlias "Ethernet" -Detailedwhere -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
Clear-DnsClientCacheViewing the DNS Cache
Get-DnsClientCache | Select-Object Entry, DataEntry 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.17Querying Specific Cache Entries
Clear-DnsClientCache
Get-DnsClientCache -Entry "github.com" -ErrorAction SilentlyContinue |
Select-Object -Property Entry, Type, Status, TimeToLive, Datawhere:
Clear-DnsClientCacheflushes and purges all entries in the local DNS resolver cache.Get-DnsClientCacheretrieves records stored in the client DNS cache.-Entryfilters the cache for a specific domain name.TimeToLiveis the number of seconds before the DNS record expires from cache.
./dns-cache-ops.ps1Entry Type Status TimeToLive Data
----- ---- ------ ---------- ----
github.com A Success 240 140.82.112.4Practical 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.
$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.
./network-config-report.ps1Adapter : 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.1Client 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.
$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.Statusvalidates the physical link state before running queries.$ipConfig.IPv4DefaultGateway.NextHopretrieves the IP address string of the configured gateway router.Test-Connection -Quietreturns$trueor$falseto verify gateway reachability.
./diagnose-client-network.ps1DNS 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