#***************************************************************************************

# Written by Michael Pomfret

#

# This script downloads and instals SharePoint 2013 Prerequisites

#

# -Only run this script on Windows Server 2012 (RTM, either Standard or Datacenter)

# -Do not run this script on a Windows Server 2008 R2 SP1 Server!

# —These are the Prerequisites for Windows Server 2012

# -Run this script as a local server Administrator

# -Run PowerShell as Administrator

#

# The SharePoint 2013 prerequisite installer (prerequisiteinstaller.exe) installs the following software, if it has not already been installed on the target server, in this order:

#

# 1.Microsoft .NET Framework version 4.5

# 2.Windows Management Framework 3.0

# 3.Application Server Role, Web Server (IIS) Role

# 4.Microsoft SQL Server 2008 R2 SP1 Native Client

# 5.Windows Identity Foundation (KB974405)

# 6.Microsoft Sync Framework Runtime v1.0 SP1 (x64)

# 7.Windows Identity Extensions

# 8.Microsoft Information Protection and Control Client

# 9.Microsoft WCF Data Services 5.0

# 10.Windows Server AppFabric

# 11.Cumulative Update Package 1 for Microsoft AppFabric 1.1 for Windows Server (KB 2671763)

#

# IMPORTANT NOTES:

# -The $SharePoint2013Path is the path to your SharePoint 2013 installation media

# -This script utilizes the PrerequisiteInstaller.exe in your SharePoint 2013 media

# -The script points to your $SharePoint2013Path\PrerequisiteInstallerFiles directory.

# —BE SURE TO COPY THE PREREQ FILES INTO THIS DIRECTORY IF THEY ARE NOT ALREADY THERE FROM THE Download-SP2013PreReqFiles.ps1 script

#

# Don’t forget to: Set-ExecutionPolicy RemoteSigned

# If you have not done so already within you Windows Server 2012 server

#****************************************************************************************

param([string] $SharePoint2013Path = $(Read-Host -Prompt “Please enter the directory path to where your SharePoint 2013 installation files exist.”))

function InstallPreReqFiles()

{

$ReturnCode = 0

Write-Host “”

Write-Host “=====================================================================”

Write-Host “Installing Prerequisites required for SharePoint 2013”

Write-Host “”

Write-Host “This uses the supported installing offline method”

Write-Host “”

Write-Host “If you have not installed the necessary Roles/Features”

Write-Host “this will occur at this time.”

Write-Host “=====================================================================”

Try

{

Start-Process “$SharePoint2013Path\PrerequisiteInstaller.exe” -ArgumentList “`

/SQLNCli:`”$SharePoint2013Path\PrerequisiteInstallerFiles\sqlncli.msi`” `

/NETFX:`”$SharePoint2013Path\PrerequisiteInstallerFiles\NDP451-KB2858728-x86-x64-AllOS-ENU.exe`” `

/IDFX:`”$SharePoint2013Path\PrerequisiteInstallerFiles\Windows6.1-KB974405-x64.msu`” `

/IDFX11:`”$SharePoint2013Path\PrerequisiteInstallerFiles\MicrosoftIdentityExtensions-64.msi`” `

/Sync:`”$SharePoint2013Path\PrerequisiteInstallerFiles\Synchronization.msi`” `

/AppFabric:`”$SharePoint2013Path\PrerequisiteInstallerFiles\WindowsServerAppFabricSetup_x64.exe`” `

/KB2671763:`”$SharePoint2013Path\PrerequisiteInstallerFiles\AppFabric1.1-RTM-KB2671763-x64-ENU.exe`” `

/MSIPCClient:`”$SharePoint2013Path\PrerequisiteInstallerFiles\setup_msipc_x64.msi`” `

/WCFDataServices:`”$SharePoint2013Path\PrerequisiteInstallerFiles\WcfDataServices.exe`”

/PowerShell:`”$SharePoint2013Path\PrerequisiteInstallerFiles\Windows6.1-KB2506143-x64.msu`””

}

Catch

{

$ReturnCode = -1

Write-Error $_

break

}

return $ReturnCode

}

function CheckProvidedSharePoint2013Path()

{

$ReturnCode = 0

Try

{

# Check if destination path exists

If (Test-Path $SharePoint2013Path)

{

# Remove trailing slash if it is present

$script:SharePoint2013Path = $SharePoint2013Path.TrimEnd(‘\’)

$ReturnCode = 0

}

Else {

$ReturnCode = -1

Write-Host “”

Write-Warning “Your specified download path does not exist. Please verify your download path then run this script again.”

Write-Host “”

}

}

Catch

{

$ReturnCode = -1

Write-Warning “An error has occurred when checking your specified download path”

Write-Error $_

break

}

return $ReturnCode

}

function InstallPreReqs()

{

$rc = 0

$rc = CheckProvidedSharePoint2013Path

# Install the Pre-Reqs

if($rc -ne -1)

{

$rc = InstallPreReqFiles

}

if($rc -ne -1)

{

Write-Host “”

Write-Host “Script execution is now complete!”

Write-Host “”

}

}

InstallPreReqs

New-ItemProperty HKLM:\System\CurrentControlSet\Control\Lsa\MSV1_0 -Name “BackConnectionHostNames” -value