I can easily disable a network device via something like:
$wmi = gwmi win32_networkadapter -filter "name LIKE '$target%'" $wmi.disable()
or in newer Windows versions:
get-netadapter -InterfaceDescription "$target*" | Disable-NetAdapter -Confirm:$false
If a disabled device (e.g. a USB-to-Ethernet adapter) is physically unplugged, it will again identify as disabled when it is plugged back in.
I can re-enable using similar code, but ONLY if the device is physically connected.
- WMI is able to return the adapter, but the "enable()" method gives an "Invalid method Parameter(s) " error.
- Get-NetAdapter returns nothing if the device is not present.
How can I enable it when it is not physically present so that it will work when it is re-connected? IOW, where is the "disabled" status of a device stored, and can it be programmatically flipped?