Skip to content

Instantly share code, notes, and snippets.

@cmd64
Last active August 19, 2021 12:54
Show Gist options
  • Save cmd64/869f87b3b17c8707fa606f1451dc84d1 to your computer and use it in GitHub Desktop.
Save cmd64/869f87b3b17c8707fa606f1451dc84d1 to your computer and use it in GitHub Desktop.
[Powershell] SharePoint 2016 Download Prerequisite Files For Offline Installer.ps1
Import-Module BitsTransfer
$destPath = "C:\SP16PreReqFiles"
$destPath = $destPath.TrimEnd('\')
function validatePath($destFolder){
## Check that the path entered is valid
If (!(Test-Path $destFolder -Verbose)) {
New-Item -Path $destFolder -ItemType Directory
}
}
function downloadFiles($urlList, $location) {
if ($location -eq "SPPR") {$destFolder = $destPath}
validatePath -destFolder $destFolder
$destFolder | Out-File "$destPath\SP16PreReqFilesPath.txt" -Force
ForEach ($url in $urlList) {
$destFileName = $url.Split('/')[-1]
$destination = "$destFolder\$destFileName"
Try {
If (!(Test-Path $destination)) {
Write-Host("Downloading " + $url)
Start-BitsTransfer -Source $url -Destination $destination -DisplayName "Downloading `'$destFileName`' to $destFolder" -Priority High -Description "From $url..." -ErrorVariable err
If ($err) {Throw ""}
}
Else {
Write-Host " - File $destFileName already exists, skipping..."
}
}
Catch {
Write-Warning " - An error occurred downloading `'$destFileName`'" | Out-Null
$counter = 0
if ($counter -lt 3) {
$counter ++
Write-Warning("Retrying Download in 3 seconds...")
Start-Sleep -Seconds 3
downloadFiles -urlList $urlList -location $location
}
Else {
$counter = 0
break
}
}
}
return $destFolder
}
function getSPPRurls() {
$SPPRList = ("https://download.microsoft.com/download/4/B/1/4B1E9B0E-A4F3-4715-B417-31C82302A70A/ENU/x64/sqlncli.msi",
# Microsoft SQL Server 2012 SP1 Native Client
"https://download.microsoft.com/download/B/9/D/B9D6E014-C949-4A1E-BA6B-2E0DEBA23E54/SyncSetup_en.x64.zip",
# Microsoft Sync Framework Runtime v1.0 SP1 (x64)
"https://download.microsoft.com/download/A/6/7/A678AB47-496B-4907-B3D4-0A2D280A13C0/WindowsServerAppFabricSetup_x64.exe",
# Windows Server AppFabric 1.1
"https://download.microsoft.com/download/0/1/D/01D06854-CA0C-46F1-ADBA-EBF86010DCC6/rtm/MicrosoftIdentityExtensions-64.msi",
# Microsoft Identity Extensions (Windows Identity Foundation v1.1)
"https://download.microsoft.com/download/3/C/F/3CF781F5-7D29-4035-9265-C34FF2369FA2/setup_msipc_x64.exe",
# Microsoft Information Protection and Control Client
"https://download.microsoft.com/download/F/1/0/F1093AF6-E797-4CA8-A9F6-FC50024B385C/AppFabric-KB3092423-x64-ENU.exe",
# Cumulative Update 7 (KB3092423) for Microsoft AppFabric 1.1 for Windows Server
"https://download.microsoft.com/download/1/C/A/1CAA41C7-88B9-42D6-9E11-3C655656DAB1/WcfDataServices.exe",
# Microsoft WCF Data Services 5.6
"https://download.microsoft.com/download/5/7/2/57249A3A-19D6-4901-ACCE-80924ABEB267/ENU/x64/msodbcsql.msi",
# Microsoft ODBC Driver 11 for SQL Server
"https://download.microsoft.com/download/C/3/A/C3A5200B-D33C-47E9-9D70-2F7C65DAAD94/NDP46-KB3045557-x86-x64-AllOS-ENU.exe",
# Microsoft .NET Framework 4.6
"https://download.microsoft.com/download/3/C/F/3CF781F5-7D29-4035-9265-C34FF2369FA2/setup_msipc_x64.exe",
# Microsoft Information Protection and Control Client
"https://download.microsoft.com/download/1/6/B/16B06F60-3B20-4FF2-B699-5E9B7962F9AE/VSU_4/vcredist_x64.exe",
# Visual C++ Redistributable Package for Visual Studio 2012
"https://download.microsoft.com/download/9/3/F/93FCF1E7-E6A4-478B-96E7-D4B285925B00/vc_redist.x64.exe"
# Visual C++ Redistributable for Visual Studio 2015
)
$destURL = downloadFiles -urlList $SPPRList -location "SPPR"
$bustedPOSH = !($destURL -is [string])
if ($bustedPOSH) {
Write-Host(" - Implementing PowerShell Bug Workaround...")
$destURL = $destURL.FullName
}
unzipSyncFiles -desturl $destURL
}
function unzipSyncFiles($destURL) {
$destURL = $destURL.Trim()
Add-Type -assembly "system.io.compression.filesystem"
$zipBackUpPath = $destURL + "\SyncSetup_en.x64.zip"
$zipDestination = $destURL + "\SyncSetup_en.x64"
$path = $zipDestination + "\Microsoft Sync Framework\Synchronization.msi"
$destination = $destURL + "\Synchronization.msi"
if (Test-Path $destination) {
Write-Host(" - Synchronization.msi is already extracted...")
}
if (!(Test-Path $destination)) {
Write-Host(" - Extracting SyncSetup_en.x64.zip to: $zipDestination")
if (Test-Path $zipDestination) {
Write-Host("Removing Unzipped Folder from: $zipDestination")
Remove-Item $zipDestination -Recurse -Force
}
[io.compression.zipfile]::ExtractToDirectory($zipBackUpPath, $zipDestination)
Copy-Item -Path $path -Destination $destination
Write-Host(" - Synchronization.msi unzipped and moved to folder")
}
}
validatePath -destFolder $destPath
getSPPRurls
#SharePoint 2016 ISO Drive
$PreRequsInstallerPath= "E:"
#SharePoint 2016 Prerequisite Files Path
$PreRequsFilesPath = "C:\SP16PreReqFiles"
Start-Process "$PreRequsInstallerPath\PrerequisiteInstaller.exe" -Wait -ArgumentList " `
/SQLNCli:`"$PreRequsFilesPath\sqlncli.msi`" `
/idfx11:`"$PreRequsFilesPath\MicrosoftIdentityExtensions-64.msi`" `
/Sync:`"$PreRequsFilesPath\Synchronization.msi`"`
/AppFabric:`"$PreRequsFilesPath\WindowsServerAppFabricSetup_x64.exe`" `
/kb3092423:`"$PreRequsFilesPath\AppFabric-KB3092423-x64-ENU.exe`" `
/MSIPCClient:`"$PreRequsFilesPath\setup_msipc_x64.exe`" `
/wcfdataservices56:`"$PreRequsFilesPath\WcfDataServices.exe`" `
/odbc:`"$PreRequsFilesPath\msodbcsql.msi`" `
/msvcrt11:`"$PreRequsFilesPath\vc_redist.x64.exe`" `
/msvcrt14:`"$PreRequsFilesPath\vcredist_x64.exe`" `
/dotnetfx:`"$PreRequsFilesPath\NDP46-KB3045557-x86-x64-AllOS-ENU.exe`""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment