So far I have this:
It basically works, but the removing part removes WAAAAYY yoo many devices, needless to say it's buggy as shizne.
Code:
$strComputer = "."
$objWMIService = GetObject("winmgmts:\\" + $strComputer + "\root\cimv2")
$colItems = $objWMIService.ExecQuery("Select * from Win32_PNPEntity Where ConfigManagerErrorCode <> 0")
For Each $objItem in $colItems
? "Name: " + $objItem.Name
? "Attempting to Remove " + $objItem.Name
$DeviceID = CStr($objItem.DeviceID)
Shell "%comspec% /c %windir%\system32\devcon.exe remove " + "$DeviceID"
Next
Shell "%comspec% /c %windir%\system32\devcon.exe rescan"
[edit]
Just forget the way devcon removes hardware, it does indeed remove hardware but also hardware you did not specify, basically it sucks, im not spending more time on devcon for removing hardware.
Edited by apronk (2006-02-08 02:27 PM)