Skip to content

Instantly share code, notes, and snippets.

@PCfromDC
Last active November 14, 2017 20:20
Show Gist options
  • Save PCfromDC/2bf861e99bdf5b13676c to your computer and use it in GitHub Desktop.
Save PCfromDC/2bf861e99bdf5b13676c to your computer and use it in GitHub Desktop.
sp2016 Install Prerequisite Files
# set varibles
$sp2016Location = "D:\" # Change to folder location of SharePoint prerequisiteinstaller.exe file
$destPath = "C:\tempDownloads"
$sp2016preReqPath = Get-Content "$destPath\sp2016preReqPath.txt"
Import-Module Servermanager
#region Create variable paths and copy files
$sp2016preReqPath = $sp2016preReqPath.TrimEnd('\')
$sp2016Location = $sp2016Location.TrimEnd('\')
$filterLoc = $sp2016Location + "\prerequisiteinstallerfiles\filterpack"
$filterDest = $sp2016preReqPath + "\prerequisiteinstallerfiles"
$preLoc = $sp2016Location + "\prerequisiteinstaller.exe"
# Copy prerequisiteinstaller, Visual C++ dll, and filterpack
Copy-Item "$sp2016Location\vcruntime140.dll" $sp2016preReqPath -Force
Copy-Item $preLoc $sp2016preReqPath -Force
Copy-Item $filterLoc $filterDest -Recurse -Force
#endregion
#region Install Prerequisites
function installSP2016Files($path) {
$arguments = @(
"/unattended",
"/SQLNCli:`"$path\sqlncli.msi`"",
"/Sync:`"$path\Synchronization.msi`"",
"/AppFabric:`"$path\WindowsServerAppFabricSetup_x64.exe`"",
"/IDFX11:`"$path\MicrosoftIdentityExtensions-64.msi`"",
"/MSIPCClient:`"$path\setup_msipc_x64.exe`"",
"/KB3092423:`"$path\AppFabric-KB3092423-x64-ENU.exe`"",
"/WCFDataServices56:`"$path\WcfDataServices.exe`"",
"/ODBC:`"$path\msodbcsql.msi`"",
"/DotNetFx:`"$path\NDP46-KB3045557-x86-x64-AllOS-ENU.exe`"",
"/MSVCRT11:`"$path\vcredist_x64.exe`"",
"/MSVCRT14:`"$path\vc_redist.x64.exe`""
)
$setupFile = "$path\prerequisiteinstaller.exe"
$cmd = "$setupFile $arguments"
Start-Process $setupFile -ArgumentList $arguments -Verbose -Wait
for ($i = 10; $i -gt 0; $i--) {
Write-Host("$env:COMPUTERNAME will reboot in $i seconds")
Start-Sleep -Seconds 1
}
Restart-Computer -Force
}
#endregion
#region Check if files exist
function checkPath($path) {
# Check if destination path exists
If (!(Get-ChildItem -Path $path -ErrorAction -0).Exists) {
Write-Host("$path does not exist. Please validate the location and try agian.")
exit
}
}
#endregion
#region call functions
checkPath -path $sp2016preReqPath
checkPath -path $preLoc
installSP2016Files -path $sp2016preReqPath
#endregion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment