Skip to content

Instantly share code, notes, and snippets.

@skive
Last active September 12, 2019 21:13
Show Gist options
  • Save skive/6b6c4991e9dc47c8292bef737de6b92f to your computer and use it in GitHub Desktop.
Save skive/6b6c4991e9dc47c8292bef737de6b92f to your computer and use it in GitHub Desktop.
Remove erroneous Hyper-V network adapters
# Should be run under SYSTEM user
$Devs = Get-PnpDevice -class net | ? Status -eq Error | Select FriendlyName,InstanceId
ForEach ($Dev in $Devs) {
Write-Host "Incorrect device $($Dev.FriendlyName) $($Dev.InstanceId)" -ForegroundColor Yellow
$RemoveKey = "HKLM:\SYSTEM\CurrentControlSet\Enum\$($Dev.InstanceId)"
Write-Host "Removing ${RemoveKey}..." -ForegroundColor White
Get-Item $RemoveKey | Select-Object -ExpandProperty Property | %{ Remove-ItemProperty -Path $RemoveKey -Name $_ -Verbose }
}
Write-Host "Done. Please restart." -ForegroundColor Green
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment