One of the most powerful features in MDT is the option of having the Task Sequence install all the Roles and Features needed, most often on servers, but also for clients. I use this feature heavily in different kinds of automated datacenter builds and when preparing Proof-Of-Concept or other demo/lab type environments.
To use it, simply add the Install Roles and Features action to your Task Sequence. If you are using the default task sequence templates you would normally add it into the restore phase, but it can really be added at any time when the full operating system is up and running.

How does Install Roles and Feature action work?
Depending on target operating system the ZTIOSRole.wsf script does things a bit differently
- Windows Server 2003 – ZTIOSRole.wsf creates an answer file for sysocmgr.exe and then starts sysocmgr.exe with that answer file
- Windows Server 2008/2008R2 (not core editions) – ZTIOSRole.wsf creates an answer file for servermanagercmd.exe and then starts servermanagercmd.exe with that answer file
- Windows Server 2008/2008R2 core editions – ZTIOSRole.wsf calls ocsetup.exe directly
- Windows 7 – ZTIOSRole.wsf calls dism.exe directly
Explanation of the (Win7), (2008R2) and (Win7,Core) entries
In the Install Roles and Features action you will see various comments after some of the roles, role services and features. Here is what they really mean.
- (Win7) – The role/feature is available for Windows 7 and Windows Server 2008 R2, but not Core editions.
- (Win7,2008R2) – Same as above 🙂
- (2008R2) – The role/feature is available only for Windows Server 2008 R2 , but not Core editions
- (Core) – The role/feature is available only for Windows Server 2008 R2, including core editions
- (Win7,Core) – The role/feature is available for Windows 7 and Windows Server 2008 R2, including Core editions.
Roles for Windows Server 2003
The following roles are supported for Windows Server 2003
- IIS server
- Teminal Server
- Windows Deployment Services
- DNS
- DHCP
- WINS-Server
Windows Server 2008 considerations
Please be aware of that not all roles (like File-Service) are available to be installed via ServerManagerCmd.exe (which MDT is using) in Windows Server 2008, they are only available in Windows Server 2008 R2. However, if you select a role service that is using that role it will be automatically added. As an example, to install the File Services role for Windows Server 2008 (not R2), only select the "File Server (Core)" role service under the "File Service" node in the Install Roles and Features, do not check the "File Service" node.


Sample for installing the File-Services role in Windows Server 2008, note that the File Servcies node is not selected
Troubleshooting
As always, check the logs. The script performing the Install Roles and Features action is the ZTIOSRole.wsf script, so you can either look in the ZTIOSRole.log directly, or in the BDD.log, in the ZTIOSRole section. During deployment these files will be in C:\MININT\SMSOSD\OSDLOGS and after deployment is completed you will find them in C:\Windows\Temp\DeploymentLogs.
You will also want to review the Roles.xml and ServerMgr.log files in the %Temp% directory.
/ Johan
Hi,
Sorry for the late reply,
I have tested this on Windows Server 2012 (Full) without any problems. Try out the machine into a staging OU with no policies and see if the issue still occur.
/ Johan
I am currently using MDT 2012 U1 with SCCM 2012 SP1 and am currently working on OSD for Windows Server 2012 Full and Core. I have an MDT task sequence within SCCM and one of the items within the task sequence that I have added is MDT's Install Roles and Features task. When I select any of the items for Server 2012 and then run the task sequence, none of the items I selected installed. In following this artlcle (was recommended by Microsoft), I checked the BDD.log on the server and it indicates that the ZTIOSRole script attempts to set… Read more »
Absolutely, it's just an additonal action in the task sequence that runs the integration script…
/ Johan
Can this also be done with sccm with mdt integration?
Good description, the MDT documentation is kind of lacking (sorry about that), but ZTIRoles is one of the quickest ways to add features for a server. THanks!