The topic of today is how you can work with pnputil.exe to enable and disable devices on your computer.
This was some research and experiments I did to find alternative or complimentary ways to the GUI and PowerShell cmdlets.
By using pnputil.exe /? in PowerShell I found out what some of the uses are and the commands that I was interested in are the following.
To enumerate
This command basically lists all your current devices and their unique ID, in this case it is called Instance ID. Let's say you want to disable a speaker, then you need to find the Instance ID for that speaker.
pnputil /enum-devices
Should you need to enumerate classes for some reason, then this is the command.
pnputil /enum-classes
To disable device
Simply take the full Instance ID for the device, brackets and all.
pnputil /disable-device "SWD\PRINTENUM\{283C1D7C-527C-4D85-8FE7-BCFA6768EA32}"
This example disables Microsoft Print to PDF.
To enable device
It is very much like the previous example, you use the Instance ID to enable the device.
pnputil /enable-device "SWD\PRINTENUM\{283C1D7C-527C-4D85-8FE7-BCFA6768EA32}"
If you keep the device manager open at the same time, you will notice it flicker as the device is enabled/disabled.
Additional examples
You need to run this as an administrator, what you can do for example is to create a simple .ps1 file and then point a shortcut on that file. Then right click the shortcut and run as administrator.