Forked from rgl/Remove-VirtualBoxHostOnlyNetworkInterfaces.ps1
Created
April 1, 2018 08:34
-
-
Save aduzsardi/c83f17a6556eb3ef41d5b8274760e39b 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