Skip to content

Instantly share code, notes, and snippets.

@manelrodero
Last active July 2, 2022 16:36
Show Gist options
  • Save manelrodero/4c58e346fbc18e8ae25e9ecb133e4e74 to your computer and use it in GitHub Desktop.
Save manelrodero/4c58e346fbc18e8ae25e9ecb133e4e74 to your computer and use it in GitHub Desktop.
Script to download all the software needed to implement Johan Arwidmark's Hydration Kit
<#
.SYNOPSIS
Script to download all the software needed to implement Johan Arwidmark's Hydration Kit.
.DESCRIPTION
This script downloads all the software needed to implement Johan Arwidmark's Hydration Kit
(Windows Server, SQL Server, Configuration Manager, Windows ADK, etc.)
.NOTES
Created : 1 July 2022
Modified : 2 July 2022
Version : 1.2
Author : Manel Rodero
Twitter : @manelrodero
Blog : https://www.manelrodero.com/
Disclaimer:
This script has only been tested with PowerShell 5.1.
This script is provided "AS IS" with no warranties, confers no rights and is not supported by the author.
.PARAMETER HydrationKitBase
Specifies the directory to which the software will be downloaded and the installers will be extracted.
It is recommended that you do not use a directory with a name that contains spaces.
This script will create this structure:
X:\HydrationKitBase
<dir> Downloads (Software and other components downloaded automatically)
<dir> Setup (Components ready to be added to the 'CMLab' share)
<dir> Temp (Temporary directory)
.PARAMETER UseEvaluation
Specifies whether you want to use evaluation versions of Microsoft products (Windows, SQL Server, Configuration Manager)
The default option is $true.
.EXAMPLE
.\Download-SoftwareForHydrationKit.ps1 -HydrationKitBase "D:\HydrationKitBase"
Download all required software for Hydration Kit to D:\HydrationKitBase, including evaluation
versions of Microsoft Windows, SQL Server, and Configuration Manager.
.EXAMPLE
.\Download-SoftwareForHydrationKit.ps1 -HydrationKitBase "D:\HydrationKitBase" -UseEvaluation $false
Download all the necessary software for the Hydration Kit to D:\HydrationKitBase.
As it does not include the evaluation versions of Microsoft Windows, SQL Server and Configuration Manager,
it will be necessary to download the ISOs of these products manually.
#>
#Requires -Version 5.1
[CmdletBinding(SupportsShouldProcess=$true)]
param(
[parameter(Mandatory=$true, HelpMessage="Specify the directory to which the software will be downloaded.")]
[ValidateNotNullOrEmpty()]
[string]$HydrationKitBase,
[parameter(Mandatory=$false, HelpMessage="Specify whether you want to use evaluation versions of Microsoft products.")]
[ValidateSet($false,$true)]
[boolean]$UseEvaluation = $true
)
# Function to color the text
Function Write-Color ($Color, $Text) {
$t = $host.ui.RawUI.ForegroundColor
$host.ui.RawUI.ForegroundColor = $Color
Write-Output $Text
$host.ui.RawUI.ForegroundColor = $t
}
# Verify that the hydration kit base directory does not exist
If (Test-Path -Path $HydrationKitBase) {
Write-Warning "The hydration kit base directory already exists. Please rename or delete it and try again. Aborting..."
Break
}
# Verify that curl.exe exists
curl.exe --help | Out-Null
If ($LASTEXITCODE -ne 0) {
Write-Warning "This script requires curl.exe. Use a newer version of Windows. Aborting..."
Break
}
# Directory structure
$HKDownloads = "$HydrationKitBase\Downloads"
$HKSetup = "$HydrationKitBase\Setup"
$HKTemp = "$HydrationKitBase\Temp"
# Create directory structure
Write-Color "Blue" "Creating directory structure in '$HydrationKitBase' ..."
New-Item -ItemType Directory -Path "$HydrationKitBase" | Out-Null
New-Item -ItemType Directory -Path "$HKDownloads" | Out-Null
New-Item -ItemType Directory -Path "$HKSetup" | Out-Null
New-Item -ItemType Directory -Path "$HKTemp" | Out-Null
# Download all the software needed
Write-Color "Green" "Downloading Hydration Kit ..."
$URI = [uri]"https://github.com/DeploymentResearch/HydrationKitWS2022/archive/refs/heads/main.zip"
$File = "HydrationKitWS2022.zip"
# Invoke-WebRequest -Uri $URI -OutFile "$HKDownloads\$File"
curl.exe -L -k -o "$HKDownloads\$File" $URI
Write-Color "Cyan" "Extracting Hydration Kit in '$HKSetup\HydrationKit' ..."
Expand-Archive -Path "$HKDownloads\$File" -DestinationPath "$HKSetup"
Rename-Item -Path "$HKSetup\HydrationKitWS2022-main" -NewName "HydrationKit"
Write-Color "Green" "Downloading MDT 8456 ..."
$URI = [uri]"https://download.microsoft.com/download/3/3/9/339BE62D-B4B8-4956-B58D-73C4685FC492/MicrosoftDeploymentToolkit_x64.msi"
$File = $URI.Segments[-1]
curl.exe -L -k -o "$HKDownloads\$File" $URI
Write-Color "Green" "Downloading MDT 8456 HotFix KB4564442 ..."
$URI = [uri]"https://download.microsoft.com/download/3/0/6/306AC1B2-59BE-43B8-8C65-E141EF287A5E/KB4564442/MDT_KB4564442.exe"
$File = $URI.Segments[-1]
curl.exe -L -k -o "$HKDownloads\$File" $URI
# https://docs.microsoft.com/en-us/troubleshoot/windows-client/deployment/command-switches-supported-by-self-extractor-package
Write-Color "Cyan" "Extracting MDT 8456 HotFix in '$HKSetup\MDT 8456 HotFix' ..."
Start-Process -FilePath "$HKDownloads\$File" -ArgumentList "/extract:`"$HKSetup\MDT 8456 HotFix`" /quiet" -Wait
Write-Color "Green" "Downloading BGInfo ..."
$URI = [uri]"https://download.sysinternals.com/files/BGInfo.zip"
$File = $URI.Segments[-1]
curl.exe -L -k -o "$HKDownloads\$File" $URI
If ($UseEvaluation) {
# https://www.microsoft.com/en-us/evalcenter/evaluate-windows-server-2022
# https://go.microsoft.com/fwlink/p/?linkid=2195686&clcid=0x409&culture=en-us&country=us
# Fill Form
# https://www.microsoft.com/en-us/evalcenter/download-windows-server-2022
# Select English (United States) ISO x64
# https://go.microsoft.com/fwlink/p/?LinkID=2195280&clcid=0x409&culture=en-us&country=US
Write-Color "Green" "Downloading Windows Server 2022 x64 English ISO (Evaluation) ..."
$URI = [uri]"https://software-static.download.prss.microsoft.com/sg/download/888969d5-f34g-4e03-ac9d-1f9786c66749/SERVER_EVAL_x64FRE_en-us.iso"
$File = "WindowsServer2022_Eval_x64_en-us.iso"
curl.exe -L -k -o "$HKDownloads\$File" $URI
# https://www.microsoft.com/en-us/evalcenter/evaluate-sql-server-2019
# https://go.microsoft.com/fwlink/p/?linkid=2195584&clcid=0x409&culture=en-us&country=us
# Fill Form
# https://www.microsoft.com/en-us/evalcenter/download-sql-server-2019
# Select English EXE x64
# https://go.microsoft.com/fwlink/?linkid=866664&clcid=0x409&culture=en-us&country=us
Write-Color "Green" "Downloading SQL Server 2019 x64 SSEI Wrapper (Evaluation) ..."
$URI = [uri]"https://download.microsoft.com/download/4/8/6/486005eb-7aa8-4128-aac0-6569782b37b0/SQL2019-SSEI-Eval.exe"
$File = $URI.Segments[-1]
curl.exe -L -k -o "$HKDownloads\$File" $URI
Write-Color "Cyan" "Downloading SQL Server 2019 x64 ISO (Evaluation) ..."
Start-Process -FilePath "cmd.exe" -ArgumentList "/c $HKDownloads\$File /Action=Download /MediaPath=$HKDownloads /MediaType=ISO /Quiet" -Wait
# https://www.microsoft.com/en-us/evalcenter/download-microsoft-endpoint-configuration-manager
# Select English EXE
# https://go.microsoft.com/fwlink/p/?LinkID=2195628&clcid=0x409&culture=en-us&country=US
# https://download.microsoft.com/download/f/5/5/f55e3b9c-781d-493b-932b-16aa1b2f6371/MEM_Configmgr_2203.exe?culture=en-us&country=US
Write-Color "Green" "Downloading Configuration Manager Current Branch 2203 (Evaluation) ..."
$URI = [uri]"https://download.microsoft.com/download/f/5/5/f55e3b9c-781d-493b-932b-16aa1b2f6371/MEM_Configmgr_2203.exe"
$File = "MEM_ConfigManager_2203_Eval.exe"
curl.exe -L -k -o "$HKDownloads\$File" $URI
}
Write-Color "Green" "Downloading SQL Server 2019 x64 CU 16 ..."
$URI = [uri]"https://download.microsoft.com/download/6/e/7/6e72dddf-dfa4-4889-bc3d-e5d3a0fd11ce/SQLServer2019-KB5011644-x64.exe"
$File = $URI.Segments[-1]
curl.exe -L -k -o "$HKDownloads\$File" $URI
Write-Color "Green" "Downloading SQL Server 2019 Reporting Services ..."
$URI = [uri]"https://download.microsoft.com/download/1/a/a/1aaa9177-3578-4931-b8f3-373b24f63342/SQLServerReportingServices.exe"
$File = $URI.Segments[-1]
curl.exe -L -k -o "$HKDownloads\$File" $URI
Write-Color "Green" "Downloading SQL Server Management Studio ..."
$URI = [uri]"https://download.microsoft.com/download/8/a/8/8a8073d2-2e00-472b-9a18-88361d105915/SSMS-Setup-ENU.exe"
$File = $URI.Segments[-1]
curl.exe -L -k -o "$HKDownloads\$File" $URI
Write-Color "Green" "Downloading Windows ADK for Windows 11 21H2 (web installer) ..."
$URI = [uri]"https://download.microsoft.com/download/1/f/d/1fd2291e-c0e9-4ae0-beae-fbbe0fe41a5a/adk/adksetup.exe"
$File = $URI.Segments[-1]
curl.exe -L -k -o "$HKDownloads\$File" $URI
Write-Color "Cyan" "Creating layout in '$HKSetup\Windows ADK 11' ..."
Start-Process -FilePath "$HKDownloads\$File" -ArgumentList "/layout `"$HKSetup\Windows ADK 11`" /quiet /ceip off" -Wait
Write-Color "Green" "Downloading WinPE add-on for Windows ADK (web installer) ..."
$URI = [uri]"https://download.microsoft.com/download/5/5/e/55e3e34a-5708-46cd-a90d-92044c29336b/adkwinpeaddons/adkwinpesetup.exe"
$File = $URI.Segments[-1]
curl.exe -L -k -o "$HKDownloads\$File" $URI
Write-Color "Cyan" "Creating layout in '$HKSetup\Windows ADK 11 WinPE Addon' ..."
Start-Process -FilePath "$HKDownloads\$File" -ArgumentList "/layout `"$HKSetup\Windows ADK 11 WinPE Addon`" /quiet /ceip off" -Wait
Write-Color "Green" "Downloading SQL Server 2019 Express x64 (SSEI Wrapper) ..."
$URI = [uri]"https://download.microsoft.com/download/7/f/8/7f8a9c43-8c8a-4f7c-9f92-83c18d96b681/SQL2019-SSEI-Expr.exe"
$File = $URI.Segments[-1]
curl.exe -L -k -o "$HKDownloads\$File" $URI
Write-Color "Cyan" "Downloading SQL Server 2019 Express x64 (EXE) ..."
Start-Process -FilePath "cmd.exe" -ArgumentList "/c $HKDownloads\$File /Action=Download /MediaPath=$HKDownloads /MediaType=Core /Quiet" -Wait
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment