This Powershell script will get a list of all hidden devices from Device Manager and remove them. Use this after moving or cloning a drive to a new physically different Computer/Motherboard.
Copy to Clipboard
$unknown_devices = Get-PnpDevice | Where-Object{$_.Status -eq 'Unknown'}
$SkipList = @()
$SkipList += 'DiskDrive'
$SkipList += 'Printer'
$SkipList += 'USB'
$SkipList += 'SoftwareDevice'
$SkipList += 'Ports'
$SkipList += 'WPD'
$SkipList += 'Image'
$SkipList += 'PrintQueue'
$SkipList += 'WSDPrintDevice'
ForEach( $dev in $unknown_devices ){
if ( $SkipList -notcontains $dev.Class ){
$dev # This will show the details of this item
pnputil /remove-device $dev.InstanceId # this will remove the specified devices. Comment this line to not remove it
}else{
#write-host "Skipping $($dev.FriendlyName)"
}
}
A more advanced (and untested by me) script is available here: https://github.com/istvans/scripts/blob/master/removeGhosts.ps1 |