Deactivate devices via script in Windows

In order to save electricity or reduce your own monitoring paranoia, it is advisable to completely disconnect devices that are not in use on your own computer. Devices such as sound boxes or webcams can be deactivated / activated in the classic way via the device manager. The whole thing also works via script. The standard way of doing this used to be devcon . Windows 10 now offers a more convenient way to do this via PowerShell .


First you determine the name or the hardware ID via the Device Manager (right click on the respective device > Details > Device Description / Hardware IDs). Alternatively you can also do this with the PowerShell command Get-PnpDevice -PresentOnly. Now you create the following PowerShell script:

a422fab8dcb43ba45cce4420e050941f

The script automatically shows the UAC dialog because it requires administrator rights and can now be called up as follows:

a422fab8dcb43ba45cce4420e050941f

XXX stands for the name or the hardware ID, YYY for the values ​​enable or disable (type can also be omitted, then the current status is negated). To call up the whole thing conveniently via a link, simply create it as follows:

a422fab8dcb43ba45cce4420e050941f

Autostart via task planning (with the options "execution independent of user account control" and "with the highest privileges") or control via keyboard hotkeys is easily possible with a tool like flimsy , for example.

Back