Installing SharePoint 2013 Prerequisites from a network share

Anyone who has tried to install SharePoint 2013 Prerequisites offline has probably come across this article:

https://technet.microsoft.com/en-us/library/ff686793.aspx

This task can be somewhat difficult because assembling the prerequisites can be time consuming and running prerequisiteinstaller.exe with an arguments file presents some challenges (See the known issues section at the end of the above article).

To solve these, I have two scripts: one that runs prerequisiteinstaller.exe with inline arguments, eliminating the need to delete the startup task on the server and one that downloads all of the required files to a share.

 

To install the prereqs from a share, run the following PowerShell script on the server you want to install SharePoint on with #path changed to the location of the network share where you have downloaded the SharePoint prerequisites:

  ##### Set Local Variables 
 #Root Prerequisites Directory 
 $PrereqRoot = "#Path” 
 #SharePoint Install Media Directory 
 $SPRoot = "#Path” 
 ##### 
 
 
 cd $SPRoot 
 .\PrerequisiteInstaller.exe /SQLNCli:"$PrereqRoot\sqlncli.msi" /PowerShell:"$PrereqRoot\Windows6.1-KB2506143-x64.msu" /NETFX:"$PrereqRoot\dotnetfx45_full_x86_x64.exe" /IDFX:"$PrereqRoot\Windows6.1-KB974405-x64.msu" /Sync:"$PrereqRoot\Synchronization.msi" /AppFabric:"$PrereqRoot\WindowsServerAppFabricSetup_x64.exe" /IDFX11:"$PrereqRoot\MicrosoftIdentityExtensions-64.msi" /MSIPCClient:"$PrereqRoot\setup_msipc_x64.msi" /WCFDataServices:"$PrereqRoot\WcfDataServices.exe" /KB2671763:"$PrereqRoot\AppFabric1.1-RTM-KB2671763-x64-ENU.exe" 
 

To download all required files to a network share, run the following on an internet connected computer with access to the fileshare you want to use.  Replace #path with the network location you want to store the prerequisites on:

  #Import Required Modules 
 Import-Module BitsTransfer 
 
 ##### Set Local Variables 
 #Define the path of the target network share 
 $TargetRoot = "#Path” 
 ##### 
 
 #Create Target if needed 
 if(!(Test-Path $TargetRoot)){ 
 New-Item $TargetRoot -ItemType Directory -Force 
 } 
   
 #Set the download targets. Note these URLs may be subject to change, check https://technet.microsoft.com/en-us/library/cc262485(v=office.15).aspx for a list of prerequisites. 
 $PrereqURLs = ( 
 #Microsoft .NET Framework version 4.5 
 "https://download.microsoft.com/download/b/a/4/ba4a7e71-2906-4b2d-a0e1-80cf16844f5f/dotnetfx45_full_x86_x64.exe", 
 
 #SQL Server 2008 R2 SP1 Native Client 
 "https://download.microsoft.com/download/9/1/3/9138773A-505D-43E2-AC08-9A77E1E0490B/1033/x64/sqlncli.msi", 
 
 #Microsoft WCF Data Services 5.0 
 "https://download.microsoft.com/download/8/F/9/8F93DBBD-896B-4760-AC81-646F61363A6D/WcfDataServices.exe", 
 
 # Microsoft Information Protection and Control Client (MSIPC) 
 "https://download.microsoft.com/download/9/1/D/91DA8796-BE1D-46AF-8489-663AB7811517/setup_msipc_x64.msi", 
 
 #Microsoft Sync Framework Runtime v1.0 SP1 (x64) 
 "https://download.microsoft.com/download/E/0/0/E0060D8F-2354-4871-9596-DC78538799CC/Synchronization.msi", 
 
 #Windows Management Framework 3.0 which includes Windows PowerShell 3.0 
 "https://download.microsoft.com/download/5/2/B/52B59966-3009-4F39-A99E-3732717BBE2A/Windows6.1-KB2506143-x64.msu", 
 
 #Windows Identity Extensions 
 "https://download.microsoft.com/download/0/1/D/01D06854-CA0C-46F1-ADBA-EBF86010DCC6/r2/MicrosoftIdentityExtensions-64.msi", 
 
 #Windows Identity Foundation (KB974405) 
 "https://download.microsoft.com/download/D/7/2/D72FD747-69B6-40B7-875B-C2B40A6B2BDD/Windows6.1-KB974405-x64.msu", 
 
 #Windows Server AppFabric 
 "https://download.microsoft.com/download/A/6/7/A678AB47-496B-4907-B3D4-0A2D280A13C0/WindowsServerAppFabricSetup_x64.exe", 
 
 #CU 1 for AppFabric 1.1 (KB2671763) 
 "https://download.microsoft.com/download/7/B/5/7B51D8D1-20FD-4BF0-87C7-4714F5A1C313/AppFabric1.1-RTM-KB2671763-x64-ENU.exe" 
 ) 
 
 #Download Files to Target 
 "Downloading Files" | Write-Host 
 
 foreach($URL in $PrereqURLs){ 
 #The folder name should be the last "/" of the URL 
 $Name = $URL.Split('/')[-1] 
 
 #Current Download 
 "$Name..." | Write-Host 
 
 #Download Files, skip if unneccesary. 
 if(!(Test-Path $TargetRoot\$Name)){ 
 Start-BitsTransfer -Source $URL -Destination $TargetRoot\$Name -Priority High 
 "Downloading...`n" | Write-Host 
 } else{ 
 "Already Downloaded`n" | Write-Host 
 } 
 } 
 
 #Acknowledgements to Muawiyah Shannak whose script this is based off of. The original can be found here https://gallery.technet.microsoft.com/Script-to-SharePoint-2013-702e07df