While running the Microsoft SharePoint 2013 Products Prepartion Tool (also known as Prerequisites Installer or prerequisiteinstaller.exe) on a Windows Server 2012 R2 machine the following error message appeared:
There was an error during installation.
The tool was unable to install Application Server Role, Web Server (IIS) Role.
This error appeared because the Prerequisites Installer was trying to install the .NET Framework 3.5 feature, but Windows Server 2012 R2 couldn’t find the required binaries. This is a known error and may be solved by moving over to the Server Manager, clicking through the feature installation and specifying an alternate source path as described here:
SharePoint 2016: Unable to install Application Server Role, Web Server (IIS) Role
SharePoint 2013: Unable to install Application, Web Server (IIS) Role
But that didn’t solve the issue this time.
Next up I tried to install the .Net Framework 3.5 manually using the .Net offline installer. But Windows Server wasn’t happy with that.
The final solution was to open the Local Group Policy Editor and browsing to Computer Configuration > Administrative Templates > System then navigate to Specify settings for optional component installation and component repair.
Enable this policy and select the checkbox beside Contact Windows Update directly to download repair content instead of Windows Server Update Services (WSUS)
The server is now able to download the .Net Framework 3.5 directly from the Windows Update servers on the Internet. I suggest to do this by Group Policy Object (GPO) in a multi-server farm.