How To: Clean Up Removed NICs in Windows 2008 VMs

It's possible (probable?) that this is common knowledge for those of you who have to deal with this every day, but I'm going to post it in hopes it's useful, and so I can document it for myself!

I've been working in the lab, trying to get all of the pieces I'll need to be able to quickly swap out products as need.  One of these tasks is putting together a clean set of VM templates of different OSes.  I created one last night for Windows 2008 R2 SP1, and I didn't see that the default NIC was an E1000.  As I went through my checklist, I realized that it was the wrong driver and so I added a new NIC to the VM, and removed the old one.

The problem came from the fact that Windows doesn't delete the hardware, it just hides it.  I could reuse the IP address that had been in place, I could reuse the connection name and BGInfo kept referring to a NIC that didn't exist.  How to get the NIC removed completely?

  1. Open a command prompt with administrative privlidges (right-click, Run as administrator)
  2. In the command prompt enter the following two commands in order:
    • SET DEVMGR_SHOW_NONPRESENT_DEVICES=1
    • START DEVMGMT.MSC
  3. The second command is very important, because if you don't start the Device Manager session from inside the elevated command prompt you just opened, you won't have the proper settings.
  4. Once Device Manager is open, go to "View" and select "Show hidden devices"
  5. Expand "Network Adapters" and you should see any VM NICs that have been removed (they will be greyed out).  Select them, right-click and choose "Uninstall"

That should clean everything up for you.  Hope this helps!