I'm assuming you are looking for a WMI way to do it, and for that I can't help. But if you are willing to use an external utility devcon is your friend.