Quantcast
Viewing all articles
Browse latest Browse all 9510

How to Bulk-Remove All Hidden Devices in Device Manager? (Sample PowerShell Script for Single Devices)

So a while back I put this together to clear devices and then re-scan:

$deviceName="Insert Device Name Here"foreach ($dev in (Get-PnpDevice | Where-Object{$_.Name -eq $deviceName})) {&"pnputil" /remove-device $dev.InstanceId }pnputil.exe /scan-devices

I used it to deal with malfunctioning USB devices, I let this script run and it deleted every USB device it could find from Device Manager, and then re-scanned for hardware so connected devices would start working again. (It was great because this would even uninstall the mouse and keyboard drivers, and then reinstall them when it re-scanned; if I didn't do that then I'd have to force a restart which is never a good thing.)

Now I want to see about doing something else. I've read that sometimes drivers for "hidden" devices can cause problems if they get outdated, so I wanted to see if there was a way to use this (or something like this) to do that? It gets tedious having to do go through and do it manually by expanding every single category.


Viewing all articles
Browse latest Browse all 9510

Trending Articles