Skip to content

PowerShell Restarting and Toggling Network Adapters

How to use PowerShell cmdlets like Restart-NetAdapter, Disable-NetAdapter, and Enable-NetAdapter to quickly fix network connectivity issues without rebooting.

Beyond viewing configuration, PowerShell can directly control the state of a network adapter, enabling, disabling, or restarting it, which is often the fastest fix for connectivity issues without rebooting the entire machine. Managing the operational lifecycle of network interfaces involves controlling both the Layer 2 hardware/driver state using the NetAdapter module and the underlying Layer 7 operating system networking services using the ServiceProcess module.

Disabling and Enabling Adapters

The Disable-NetAdapter and Enable-NetAdapter cmdlets change the software operational state of physical or virtual network interface cards (NICs). Disabling an adapter tears down its active Layer 2/3 connections, unbinds its network protocols, and halts all incoming and outgoing packet transmission.

toggle-adapter.ps1powershell
Disable-NetAdapter -Name "Wi-Fi" -Confirm:$false

$status = Get-NetAdapter -Name "Wi-Fi" | Select-Object -Property Name, Status, InterfaceDescription

Enable-NetAdapter -Name "Wi-Fi" -Confirm:$false

$status

where:

  • Disable-NetAdapter disables the target network interface at the driver and OS level.
  • -Name is the friendly alias of the network adapter (wildcards supported).
  • -Confirm:$false suppresses the interactive confirmation prompt required by default for high-impact operations.
  • Enable-NetAdapter re-initializes the adapter, rebinds protocol drivers, and resumes network transmission.
  • Get-NetAdapter queries the adapter state to confirm modification.
Consolepowershell
./toggle-adapter.ps1
Outputplaintext
Name  Status   InterfaceDescription
----  ------   --------------------
Wi-Fi Disabled Intel(R) Wi-Fi 6 AX201 160MHz

Restarting an Adapter with Restart-NetAdapter

The Restart-NetAdapter cmdlet performs a fast, sequential disable and re-enable of a network adapter in a single operation. This power-cycles the network driver, clears hardware interface queues, and forces a dynamic renegotiation of DHCP addresses and ARP tables without rebooting the host operating system.

restart-adapter-demo.ps1powershell
Restart-NetAdapter -Name "Ethernet0" -PassThru | 
    Select-Object -Property Name, Status, LinkSpeed

where:

  • Restart-NetAdapter performs a synchronous driver shutdown and restart on the specified interface.
  • -Name specifies the interface name to restart.
  • -PassThru returns the updated MSFT_NetAdapter object; by default, this cmdlet emits no output to the pipeline.
Consolepowershell
./restart-adapter-demo.ps1
Outputplaintext
Name      Status LinkSpeed
----      ------ ---------
Ethernet0 Up     1 Gbps

You can also suppress the confirmation prompt for unattended scripts:

Consolepowershell
Restart-NetAdapter -Name "Ethernet0" -Confirm:$false

Hardware Adapter Cycling vs. Network Service Cycling

A critical architectural distinction in Windows administration is separating network interfaces from network services:

Layer Component Managed Cmdlets Used Impact
Layer 1 / 2 Physical or Virtual NIC Driver Disable-NetAdapter
Enable-NetAdapter
Restart-NetAdapter
Drops the physical/virtual link. Flushes hardware buffers, resets interface link speed, drops all IP traffic.
Layer 7 Windows Network Services / Daemons Stop-Service
Start-Service
Restart-Service
Controls OS application daemons (e.g., DNS client cache, DHCP client, SMB file server) while leaving the physical network link alive.

Restarting an adapter does not restart background system services like the DNS Client (Dnscache) or the Server/SMB service (LanmanServer). Conversely, restarting a network service does not re-initialize the hardware link or reset interface hardware counters.

service-vs-adapter.ps1powershell
Restart-Service -Name "Dhcp" -Force

[PSCustomObject]@{
    DhcpServiceStatus = (Get-Service -Name "Dhcp").Status
    AdapterStatus     = (Get-NetAdapter -Name "Ethernet0").Status
}

where:

  • Restart-Service -Name "Dhcp" cycles the Windows DHCP Client service responsible for obtaining and managing dynamic IP allocations from external servers.
  • -Force forces dependent background services to restart if required.
  • Get-Service queries the operational state of the Windows service.
  • Get-NetAdapter queries the operational state of the physical network card.
Consolepowershell
./service-vs-adapter.ps1
Outputplaintext
DhcpServiceStatus AdapterStatus
----------------- -------------
          Running            Up

Practical Usage

Adapter Reset Script for Connectivity Issues

A common troubleshooting script toggles the adapter, flushes DNS, and re-tests connectivity, automating steps normally performed manually through the GUI.

reset-network-adapter.ps1powershell
param(
    [Parameter(Mandatory)]
    [string]$AdapterName,
    [string]$TestTarget = "8.8.8.8"
)

Write-Output "Restarting adapter '$AdapterName'..."
Restart-NetAdapter -Name $AdapterName -Confirm:$false

Start-Sleep -Seconds 5

Write-Output "Flushing DNS cache..."
Clear-DnsClientCache

Write-Output "Testing connectivity to $TestTarget..."
$result = Test-Connection -ComputerName $TestTarget -Count 2 -Quiet

if ($result) {
    Write-Output "Connectivity restored."
} else {
    Write-Output "Still unreachable. Manual investigation required."
}

where:

  • -Mandatory requires an adapter name to be passed to the script.
  • Start-Sleep -Seconds 5 gives the adapter time to fully reconnect before testing.
  • Clear-DnsClientCache clears stale DNS entries that may still point to outdated records.
Consolepowershell
./reset-network-adapter.ps1 -AdapterName "Ethernet"
Outputplaintext
Restarting adapter 'Ethernet'...
Flushing DNS cache...
Testing connectivity to 8.8.8.8...
Connectivity restored.

Safe Remote Adapter Reset Pipeline

When administering remote servers, power-cycling an unresponsive or degraded adapter must be handled with a fail-safe fallback to prevent locking administrators out if an interface fails to come back online.

safe-remote-restart.ps1powershell
$adapterName = "Ethernet0"

Write-Output "Initiating safe adapter restart sequence for '$adapterName'..."

$initialPing = Test-Connection -ComputerName "1.1.1.1" -Count 1 -Quiet

if (-not $initialPing) {
    Write-Warning "External connectivity is degraded. Attempting interface cycle..."
    
    Restart-NetAdapter -Name $adapterName
    
    Start-Sleep -Seconds 5
    
    $finalPing = Test-Connection -ComputerName "1.1.1.1" -Count 1 -Quiet
    
    [PSCustomObject]@{
        AdapterName     = $adapterName
        AdapterStatus   = (Get-NetAdapter -Name $adapterName).Status
        InternetRestore = $finalPing
    }
}
else {
    Write-Output "Network link is healthy. No restart required."
}

where:

  • Test-Connection -Quiet evaluates external connectivity before and after cycling the adapter.
  • Start-Sleep -Seconds 5 introduces an execution delay to give the network switch and OS time to re-establish Layer 2 carrier sense and acquire an IP lease.
  • (Get-NetAdapter -Name $adapterName).Status inspects the adapter link status to ensure it returned to the Up state.
Consolepowershell
./safe-remote-restart.ps1
Outputplaintext
Initiating safe adapter restart sequence for 'Ethernet0'...
WARNING: External connectivity is degraded. Attempting interface cycle...

AdapterName AdapterStatus InternetRestore
----------- ------------- ---------------
Ethernet0   Up                       True
Navigation