A couple of months back I wrote a post on how to automatically install pre-requisites for Exchange 2010 on a Windows 2008 (including R2) server.
I specifically talked about a method for doing this with ServerManagerCmd.exe, which is included with Windows Server 2008. However, in Windows Server 2008 R2, ServerManagerCmd is deprecated and the recommended method is to use PowerShell (as pointed out by my buddy, Josh).
The Add-WindowsFeature cmdlet in PowerShell provides the capability to add individual Windows features directly from a script. You can use Get-WindowsFeature to obtain a detailed list of available features, ones that are installed, and their “official” name if you wish to install them via PowerShell.
To install the required pre-reqs for Exchange 2010, from a PowerShell prompt, be sure to add the Server Manager module so the Add-WindowsFeature and Get-WindowsFeature cmdlets are available.
Once you have imported the module, then you can use Add-WindowsFeature to take care of the rest.
Add-WindowsFeature -Name RSAT-ADDS-Tools, RPC-over-HTTP-proxy, NET-HTTP-Activation, Web-Dyn-Compression, Web-Windows-Auth, Web-Digest-Auth, Web-Basic-Auth, Web-Lgcy-Mgmt-Console, Web-Metabase, Web-ISAPI-Ext, Web-Server -Concurrent