During Automated Build and capture, and sometimes during deployment it’s nice to be able to automate changes to the device manager (well devices, but basally the ones you se in the device manager). 

Her the Microsoft tool DEVCON comes in handy.. Lets say you need to remove some devices before you capture you master image, like unknown devices, com ports, display adapters etc. All you have to do is to make a "run Command Line"step in your TS that runs the DEVCON tool with the right parameters:

Remove Device: (In this case the comports) 

DEVCON remove USB\PNP0501*

This action will remove all instances with the Hardware ID ACPI\PNP0501 (notice the wildcard * which actually means that both com ports will be removed , ACPI\PNP0501\1 and ACPI\PNP0501\2)

The Hardware ID’s are found under the Details TAB in the device properties…

In some rare cases some devices are not discovered during deployment, even though the correct drivers are present in C:\drivers folder. You then wind up having a lot of exclamation marks in you device manager. The funny thing is, you can normally fix this by starting a "scan for Hardware changes" in your device manager, and the devices will automatically be installed.

To make sure this doesn’t happen you can add a step to your TS that does an automatic scan, at the very end of your TS.

Scan for changes:

DEVCON rescan

There are a lot of other nice things you can do with DEVCON, like Reboot, list driver files including location, and much more.

Get functions:

DEVCON ? or DEVCON help function (function being remove, rescan, reboot or some thing else)

The tool can be downloaded from Microsoft http://support.microsoft.com/kb/311272/en-us Here you will find some info on how to use it as well