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 **
update:
this works but requires a reboot. So I copied and pasted the reboot code section of the InstallPrerequisites function and added it to this function.
```
function installIISRolePreSP1($sxsfolder)
{
Disable-ServerManagerlaunchOnLogon 'disable'
# 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
$iis = Get-Service 'IISADMIN' -ErrorAction SilentlyContinue
if($iis -eq $null)
{
if (Test-Path -Path $sxsfolder)
{
Import-Module ServerManager
Write-Host ' - PreSP1 2013 version of prerequisites installed workaround install'
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
Write-Host -ForegroundColor White ' - Setting AutoSPInstaller information in the registry...'
New-Item -Path 'HKLM:\SOFTWARE\AutoSPInstaller\' -ErrorAction SilentlyContinue | Out-Null
$regKey = Get-Item -Path 'HKLM:\SOFTWARE\AutoSPInstaller\'
$regKey | New-ItemProperty -Name 'RestartRequired' -PropertyType String -Value '1' -Force | Out-Null
# We now also want to disable remote installs, or else each server will attempt to remote install to every *other* server after it reboots!
$regKey | New-ItemProperty -Name 'CancelRemoteInstall' -PropertyType String -Value '1' -Force | Out-Null
$regKey | New-ItemProperty -Name 'LogTime' -PropertyType String -Value $script:Logtime -ErrorAction SilentlyContinue | Out-Null
Throw ' - One or more of the prerequisites requires a restart.'
}
else
{
Write-Host ' - SXS folder ot found'
}
}
}
```
The server reboots and anther issue comes up:
The pre-sp1 prerequisites tool requires the servermanagercmd. this is created from a copy of the servermanager.exe file but when the prereq tools starts it launches the server manager and this background execution of the servermanager UI blocks the prereq tool and it just lasts forever. if you kill the servermanagercmd process you kill the prereq tool with it. so Solution is to stop the process gracefully using the CloseMainWindow() method like this:
```
start-sleep 10
$Process= Get-Process | Where-Object {$_.name -like 'servermanagercmd'}
$Process.CloseMainWindow()
```
these lines are added just before the these lines in the InstallPrerequisites function
```
Show-Progress -Process PrerequisiteInstaller -Color red -Interval 5
$delta,$null = (New-TimeSpan -Start $startTime -End (Get-Date)).ToString() -split '\.'
```
this kill the servermanager UI and the prereq tool continues.
This is for a setup when you don't have a sharepoint source folder with a integrated sp1.
This is also only valid for Windows 2012 R2.
In my case I have a SharePoint RTM source folder with the SP1 exe file in the updates folder.
Sorry Brian for torturing your scripts :-)
I even added a function to disable servermnager from starting on logon. this does not solve the problem. It just gets rid of the servermanager autorun annoyance.
```
Function Disable-ServerManagerlaunchOnLogon($action)
{
if ($action -eq 'disable')
{
Write-Host -ForegroundColor White " - Disabling `"ServerManager open on logon`""
Set-ItemProperty -Path 'HKLM:\Software\Microsoft\ServerManager' -Name DoNotOpenServerManagerAtLogon -Value 1
}
elseif ($action -eq 'enable')
{
Write-Host -ForegroundColor White " - Enabling `"Enabling `"ServerManager open on logon`""
Set-ItemProperty -Path 'HKLM:\Software\Microsoft\ServerManager' -Name DoNotOpenServerManagerAtLogon -Value 0
}
}
```