New
#1
Cleanup orphan/hidden devices
I have been following this thread, trying to fix the problem with the erroneous USB flask disks icons.
According to the fix recommendation -which worked perfectly- there is a need to clear all phantom USB/Volume/Portable Devices from Device Manager.
That is a cumbersome task, especially if the number of these unneeded devices grows significantly over time. In my case there were 90 of them, so I had to select 90 devices and delete them one by one in Device Manager. Apparently there was a need for a more automated process to delete them.
Trying to find a better way I came through a post from one of our distinguished fellow members, Ed Tittel
The recommended by Ed 3rd party app, seems to be working as it’s supposed to and helps delete hidden/phantom devices.
But… this, after all, is TenForums and we’re accustomed in doing things “our way”, i.e. with Microsoft’s own tools.
So to start, you can view all orphan devices, i.e. devices that are not currently connected to your computer
Open Device Manager and click View > Show hidden devices.
All devices in gray color are not currently connected to your computer.
Some of these devices, like old USB flash disks, or old external disks are not needed and can be safely removed.
This can be done in Device Manager, as said before, by pressing delete on these hidden devices.
Automating this process, to be able to delete multiple devices at once, can be done with the use of a simple PowerShell script, with the help from Microsoft’s Device console tool, DevCon.
DevCon (Devcon.exe), the Windows Device Console, is a command-line tool that displays detailed information about devices on computers running Windows. You can use DevCon to enable, disable, install, configure, and remove devices. In other words, it's the command line alternative of Device Manager.
If you don’t already have this tool, you can get it easily by following these steps.
The DevCon.exe tool is provided free of charge as part of the Windows Driver Kit.
- Use this link to download the latest Windows 10 Driver Kit. https://go.microsoft.com/fwlink/?linkid=2085767
- Run the file and choose "Download the Windows Driver Kit for installation on a separate computer.”
- Once the WDK is downloaded go to the location you saved it and within the
Installers
folder find the file787bee96dbd26371076b37b13c405890.cab
- Using 7zip (or your favorite file extractor), open the cab file and extract the file named:
filbad6e2cce5ebc45a401e19c613d0a28f
- Rename this file to devcon.exe and there you have it. The latest devcon.exe
Now to cleanup these unwanted orphan devices.
1 Go to your desktop and create a folder (e.g. Cleanup).
2 Copy the devcon.exe file and paste it in that folder.
3 Download the PowerShell script RemoveHiddenDevices.ps1.
Download
4 Save it in the Desktop folder where the devcon.exe is located and unblock it.
5 Open Powershell as Administrator and navigate to the folder where the PowerShell script and the devcon.exe reside.
If you haven't already changed the PowerShell ExecutionPolicy to allow running scripts, you need to do it. So before running the script (or any other script, from a source you trust), run the following command to allow the script to run in the current PowerShell session.
Set-ExecutionPolicy Bypass -Scope Process
Remember that closing the PowerShell window your ExecutionPolicy returns to its defaults, for every new PowerShell window (session).
6 Run the script by typing the command:.\RemoveHiddenDevices.ps1
7 Upon execution of the script, a new PowerShell window (Out-Gridview) will open, in which all the hidden devices that are allowed to be deleted will be presented, so you can select which devices you want to remove.
NoteThe hidden, orphan devices, that are allowed to be removed and will be shown in that selection window, are the ones that are greyed-out in Device Manager, under the following classes:
- Disk Drives (DiskDrive)
- Portable Devices (WPD)
- Storage Volumes (Volume)
- Universal Serial Bus Controllers (USB)
8 Go through that list carefully and select the hidden devices that you want to remove. Select all devices by pressing Ctrl+A, or select some of the devices by holding down Ctrl while selecting each device.
9 Once you selected the devices you want to remove, press the OK button at the bottom of this window.
The selection window will be closed and you will be moved to the underlying PowerShell console window where you’ll see the results of the script.
That's it. You have cleaned the hidden/orphan devices from your system.
You can now close the PowerShell window, if you wish.... as Shawn @Brink would have said!
HTH!
Last edited by ddelo; 23 Nov 2019 at 18:19.