On a clean install of Windows 2012 R2
https://social.technet.microsoft.com/Forums/office/en-US/37cc20db-6cc7-45e0-928c-9a1ddbdab2ae/the-tool-was-unable-to-install-application-server-role-web-server-iis-role?forum=sharepointadmin
I copied and then renamed, this also fixed my issue. "rename the file C:\windows\System32\ServerManager.exe with ServerManagerCMD.exe"
Comments: ** Comment from web user: SpRambler **
I finally merged two solutions found on the web and made up a function and added it to the functions file:
The function is called in the pre-sp1 prerequisites install for SharePoint 2013 on 2012 R2.
The install goes smooth without errors.
The function is a quick and dirty solution to get my setup running.... will require more work for integration into the autospinstaller tool.
function installIISRolePreSP1()
{
# copy rename servermanager.exe to servermanagercmd.exe
$sys32 = [System.Environment]::GetFolderPath('System')
Copy-Item (Join-Path $sys32 servermanager.exe) -Destination (Join-Path $sys32 servermanagercmd.exe)
# Install IIS Role from SXS folder
$sxsfolder = "$env:SPbits\PrerequisiteInstallerFiles\sxs"
if (Test-Path -Path $sxsfolder)
{
Import-Module ServerManager
Add-WindowsFeature NET-WCF-HTTP-Activation45,NET-WCF-TCP-Activation45,NET-WCF-Pipe-Activation45 -Source $sxsfolder
Add-WindowsFeature Net-Framework-Features,Web-Server,Web-WebServer,Web-Common-Http,Web-Static-Content,Web-Default-Doc,Web-Dir-Browsing,Web-Http-Errors,Web-App-Dev,Web-Asp-Net,Web-Net-Ext,Web-ISAPI-Ext,Web-ISAPI-Filter,Web-Health,Web-Http-Logging,Web-Log-Libraries,Web-Request-Monitor,Web-Http-Tracing,Web-Security,Web-Basic-Auth,Web-Windows-Auth,Web-Filtering,Web-Digest-Auth,Web-Performance,Web-Stat-Compression,Web-Dyn-Compression,Web-Mgmt-Tools,Web-Mgmt-Console,Web-Mgmt-Compat,Web-Metabase,Application-Server,AS-Web-Support,AS-TCP-Port-Sharing,AS-WAS-Support, AS-HTTP-Activation,AS-TCP-Activation,AS-Named-Pipes,AS-Net-Framework,WAS,WAS-Process-Model,WAS-NET-Environment,WAS-Config-APIs,Web-Lgcy-Scripting,Windows-Identity-Foundation,Server-Media-Foundation,Xps-Viewer,Windows-Identity-Foundation -Source %SXSFOLDER%
}
else
{
Write-Host 'SXS folder ot found'
}
}