Created
October 22, 2016 23:21
-
-
Save rgl/ed3352d676a68e259e38cd2d3bce0049 to your computer and use it in GitHub Desktop.
Remove all VirtualBox Host-Only network interfaces (Windows)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# NB this depends on devcon. you must install it from chocolatey with choco install -y devcon.portable | |
$devcon = "$ENV:ProgramData\Chocolatey\Lib\devcon.portable\Devcon$(if ($ENV:PROCESSOR_ARCHITECTURE -like '*64') {'64'} else {'32'}).exe" | |
Get-NetAdapter ` | |
| Where-Object {$_.Virtual} ` | |
| Where-Object {$_.DriverFileName -like 'VBox*.sys'} ` | |
| ForEach-Object { | |
Write-Host "Removing the $($_.InterfaceAlias) interface..." | |
$result = &$devcon remove "@$($_.PnPDeviceID)" | |
if (!($result -eq '1 device(s) were removed.')) { | |
throw "failed to remove the network interface $($_.InterfaceAlias): $result" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment