When working with Get-NetAdapter
in Windows Server 2012 (PowerShell 3.0), you might encounter network adapters showing "Not Present" status. This state appears when the network interface exists in the system but isn't physically or logically available for communication.
The "Not Present" status indicates one of several conditions:
- The physical NIC isn't detected (removed or failed hardware)
- The virtual NIC's underlying component is unavailable
- The adapter is in a "hidden" or disconnected state in the Windows NDIS stack
Example output showing different states:
Name InterfaceDescription ifIndex Status MacAddress LinkSpeed
Slot 0 Port 4 HP NC382i DP Multifunction Gigabi...#53 15 Not Present 11-80-1B-94-2A-82 0 bps
Slot 0 Port 2 (TM-2) HP NC382i DP Multifunction Gigabi...#51 14 Up 11-80-1B-94-27-72 1 Gbps
The Enable-NetAdapter
cmdlet silently fails because it can only transition between Disabled and Enabled states. The GUI performs additional initialization that PowerShell doesn't handle automatically.
Here's how to properly enable a "Not Present" adapter:
# First disable then enable to properly initialize
Disable-NetAdapter -Name "Slot 0 Port 4" -Confirm:$false
Enable-NetAdapter -Name "Slot 0 Port 4" -Confirm:$false
To intentionally set an adapter to "Not Present" state:
# Physically remove the adapter or disable the parent device
Disable-PnpDevice -InstanceId ((Get-NetAdapter -Name "Slot 0 Port 4").InterfaceDescription.Split('#')[1]) -Confirm:$false
For persistent "Not Present" issues, try these steps:
- Reset the TCP/IP stack:
netsh int ip reset
- Reinstall the driver:
pnputil /delete-driver oemNN.inf /uninstall
- Refresh hardware detection:
devcon rescan
Example script to monitor state changes:
$adapter = "Slot 0 Port 4"
while ($true) {
$state = (Get-NetAdapter -Name $adapter -ErrorAction SilentlyContinue).Status
if ($state -eq "Not Present") {
Write-Host "Adapter not present - attempting recovery"
# Add recovery logic here
}
Start-Sleep -Seconds 5
}
The "Not Present" state originates from the NDIS (Network Driver Interface Specification) stack. When an adapter is in this state, it means:
- NDIS reports the adapter as non-operational
- The miniport driver failed to initialize
- The hardware abstraction layer can't communicate with the device
For developers working with network adapters programmatically, you might encounter similar status codes when using the Windows Filtering Platform or NDIS APIs.
When working with Get-NetAdapter
in PowerShell 3.0 on Server 2012, you might encounter adapters showing a 'Not Present' status. This state is different from 'Up' or 'Disabled' and behaves unusually with PowerShell cmdlets:
# Example output showing 'Not Present' status
Get-NetAdapter | Where-Object {$_.Status -eq 'Not Present'}
Name InterfaceDescription ifIndex Status MacAddress LinkSpeed
---- -------------------- ------- ------ ---------- ---------
Slot 0 Port 4 HP NC382i DP Multifunction Gigabi...#53 15 Not Present 11-80-1B-94-2A-82 0 bps
The puzzling aspect is that while the GUI can enable these 'Not Present' adapters, Enable-NetAdapter
silently fails:
# This command will silently fail for 'Not Present' adapters
Enable-NetAdapter -Name "Slot 0 Port 4" -Confirm:$false
However, once the adapter has been toggled through the GUI to 'Up' state, PowerShell commands start working normally:
# After GUI intervention, these work as expected
Disable-NetAdapter -Name "Slot 0 Port 4" -Confirm:$false
Enable-NetAdapter -Name "Slot 0 Port 4" -Confirm:$false
The 'Not Present' status typically indicates one of these conditions:
- The physical adapter is not detected (removed or faulty hardware)
- The driver is installed but the device is in a low-power state (D3)
- The adapter exists in registry but isn't responding to queries
To properly handle 'Not Present' adapters in scripts, consider these approaches:
# Method 1: Use devcon.exe to force a reset
& "$env:ProgramFiles\Windows Kits\10\Tools\x64\devcon.exe" enable "PCI\VEN_14E4&DEV_163B"
# Method 2: Registry modification to trigger re-initialization
$regPath = "HKLM:\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}\0015"
Set-ItemProperty -Path $regPath -Name "EnableDHCP" -Value 1
Restart-NetAdapter -Name "Slot 0 Port 4"
If you need to recreate this state for testing:
# Disable the adapter completely through WMI
$adapter = Get-WmiObject -Class Win32_NetworkAdapter | Where-Object {$_.Name -eq 'Slot 0 Port 4'}
$adapter.Disable()
When writing automation scripts, always account for the 'Not Present' state:
function Enable-NetAdapterRobust {
param([string]$AdapterName)
$adapter = Get-NetAdapter -Name $AdapterName -ErrorAction SilentlyContinue
if ($adapter -and $adapter.Status -eq 'Not Present') {
Write-Verbose "Adapter in Not Present state - using alternative enable method"
$pnpid = (Get-PnpDevice | Where-Object {$_.FriendlyName -like "*$AdapterName*"}).InstanceId
& pnputil /enable-device $pnpid
}
elseif ($adapter) {
Enable-NetAdapter -Name $AdapterName -Confirm:$false
}
else {
Write-Error "Adapter not found"
}
}