PowerShell version of DEVCON.EXE or Device Manager cmdlets
DEVCON.EXE can be used to install, uninstall, enable, disable, configure or query devices (as seen in Device Manager) from the command line. Here is the description:
To get DEVCON.EXE, you have to download the entire Windows Drivers Kit (WDK), which is 803MB in size, and, as I understand it, DEVCON cannot be legally redistributed or shared separately.
It would be good to have a PowerShell cmdlet to replace DEVCON that is either installed by default or available in the PSGallery.
Or just allow DEVCON.EXE to be downloaded separately from the WDK somehow, like through NuGet, PSGallery or anywhere.
Or just allow DEVCON.EXE to be redistributed by third parties.
For example, as far as I know, DEVCON.EXE is the only supported or "clean" way to script the installation of the MS Loopback Adapter.
The PnpDevice module contains some of the features available in Devcon.exe. If there are tasks that you cannot perform using it, please let us know what is missing, along with a basic comment of why you would use them.
David McFall commented
+1 for an Uninstall-PnpDevice cmdlet. I need to uninstall a network device from system running Windows Server without a gui and it's frustrating that there doesn't seem to be a way to automate this that doesn't involve downloading a non-native utility or hunting in the registry for interface GUIDs.
Anthony Wall commented
Should this be linked or replaced with a request to add an Uninstall-PnpDevice function to the PnpDevice module? Is it open source so we could contribute this ourselves?
Sean Bober commented
I currently have a situation where I need to not only remove a particular class of device but also need to delete each class member's associated OEM.inf file. I do not believe that this is possible without devcon.exe
I need to uninstall VMWare devices on thousands of migrated machines from vmware to hyper-v
Here's how to download DevCon without downloading the entire Driver Kit:
Jason Fossen commented
The PnPDevice module is very useful, but I don't think it allows you to (un)install devices. It only provides cmdlets to query, enable or disable them, so it's not a full replacement for devcon.exe.
For my particular need, I would like to be able to install the MS Loopback Adapter without devcon.exe, but installing devices using MS or third-party drivers and INF files in general I think would be useful to others, especially for appliances.
If a new Install-PnpDevice cmdlet were added to the PnpDevice module, that would be great, but personally I think it would be enough to just have devcon.exe and a wrapper PoSh module in the PSGallery available for redistribution (or whatever DLL devcon.exe uses plus the PoSh wrapper, not necessarily devcon.exe itself).