Last active
September 2, 2024 16:55
-
-
Save turboBasic/8b570842d2165d90909fb2ef3aff98a1 to your computer and use it in GitHub Desktop.
Get-ADK.ps1 - Download & install Windows ADK. #windows #windows-adk #powershell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.SYNOPSIS | |
Get-ADK: Get and install Windows Assessment and Deployment Kit (WADK) | |
.DESCRIPTION | |
Get-ADK is utility for downloading and installing multiple versions of Windows ADK tool. | |
Usage: | |
.\Get-ADK.ps1 command [arguments] | |
commands: download, install, help | |
'download' <version>: Downloads WADK of specified version to <version> subdirectory of Get-ADK folder. Versions are 14393, 15063, 16299 | |
'install' <version>: Installs WADK of specified version to $ENV:tools directory or b:\tools in ENV:tools isn't defined | |
'help' or '?' | |
.EXAMPLE | |
.\Get-ADK.ps1 download 1709 | |
.EXAMPLE | |
.\Get-ADK.ps1 install 1607 | |
#> | |
[CmdletBinding()] | |
Param( | |
[Parameter( Mandatory, Position=0 )] | |
[ValidateScript({ | |
if ( $_.Trim() -notIn 'download', 'install', 'help', '?' ) { | |
throw "Unknown command '$_'. Commands are: install, download, help" | |
} else { | |
$True | |
} | |
})] | |
[String] $Command, | |
[String] $Version, | |
[Switch] $noop | |
) | |
# Feature Identifier | |
# Application Compatibility Toolkit (ACT) OptionId.ApplicationCompatibilityToolkit | |
# Deployment Tools OptionId.DeploymentTools | |
# Windows Preinstallation Environment (Windows PE) OptionId.WindowsPreinstallationEnvironment | |
# User State Migration Tool OptionId.UserStateMigrationTool | |
# Volume Activation Management Tool (VAMT) OptionId.VolumeActivationManagementTool | |
# Windows Performance Toolkit (WPT) OptionId.WindowsPerformanceToolkit | |
# Windows Assessment Toolkit OptionId.WindowsAssessmentToolkit | |
# Windows Assessment Services — Client OptionId.WindowsAssessmentServicesClient | |
# Windows Assessment Services OptionId.WindowsAssessmentServices | |
# Microsoft® SQL Server® 2012 Express OptionId.SqlExpress2012 | |
# .NET Framework OptionId.Netfx | |
$installFeatures = @( | |
'OptionId.DeploymentTools' | |
) -join ' ' | |
$versions = @{ | |
'10240' = '1507' | |
'10586' = '1511' | |
'14393' = '1607' | |
'15063' = '1703' | |
'16299' = '1709' | |
default = '1803' | |
} | |
$installBase = 'b:/tools/ADK' | |
############### | |
Write-Host $psBoundParameters | |
if($ENV:tools) { | |
$installBase = $installBase -replace 'b:/tools', $ENV:tools | |
} | |
if (! $Version) { | |
$Version = cmd.exe /c ver | ForEach-Object{ | |
if ($_ -match '\d+\.\d+\.(\d+)') { $Matches[1] } | |
} | |
if (! $versions.$Version) { | |
$Version = $versions.default | |
} | |
} | |
switch ($Command) { | |
'download' | |
{ | |
$instruction = { & "${psScriptRoot}\${Version}\adksetup.exe" /layout "${psScriptRoot}\${Version}\${Version}_setup_files" } | |
break | |
} | |
'install' | |
{ | |
$instruction = { & "${psScriptRoot}\${Version}\adksetup.exe" /installpath "${installBase}${Version}" /features $installFeatures } | |
break | |
} | |
{ $_ -in '?', 'help' } | |
{ | |
$instruction = { Get-Help $psCommandPath } | |
break | |
} | |
} | |
if ($Debug -or $noop) { | |
Write-Warning "Debug instruction found. The commands to be executed are:" | |
Write-Output $instruction | |
} else { | |
Invoke-Command -scriptBlock $instruction | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In case of anyone needs windows 10 userprofile backup and restore scrip.