2021-04-26 10:27:45 -07:00
|
|
|
# Copyright (c) Microsoft Corporation.
|
|
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
|
|
|
|
# REPLACE WITH DROP-TO-ADMIN-USER-PREFIX.ps1
|
|
|
|
|
|
|
|
# REPLACE WITH UTILITY-PREFIX.ps1
|
|
|
|
|
|
|
|
<#
|
|
|
|
.SYNOPSIS
|
2021-08-13 16:12:24 -07:00
|
|
|
Installs Windows PSDK/WDK
|
2021-04-26 10:27:45 -07:00
|
|
|
|
|
|
|
.DESCRIPTION
|
2021-08-13 16:12:24 -07:00
|
|
|
Downloads the Windows PSDK/DDK installer located at $Url, and installs it with the
|
2021-04-26 10:27:45 -07:00
|
|
|
correct flags.
|
|
|
|
|
|
|
|
.PARAMETER Url
|
|
|
|
The URL of the installer.
|
|
|
|
#>
|
2021-08-13 16:12:24 -07:00
|
|
|
Function InstallWindowsDK {
|
2021-04-26 10:27:45 -07:00
|
|
|
Param(
|
|
|
|
[String]$Url
|
|
|
|
)
|
|
|
|
|
|
|
|
try {
|
2021-08-13 16:12:24 -07:00
|
|
|
Write-Host "Downloading Windows PSDK or DDK $Url..."
|
2021-04-26 10:27:45 -07:00
|
|
|
[string]$installerPath = Get-TempFilePath -Extension 'exe'
|
|
|
|
curl.exe -L -o $installerPath -s -S $Url
|
2021-08-13 16:12:24 -07:00
|
|
|
Write-Host 'Installing...'
|
2021-04-26 10:27:45 -07:00
|
|
|
$proc = Start-Process -FilePath $installerPath -ArgumentList @('/features', '+', '/q') -Wait -PassThru
|
|
|
|
$exitCode = $proc.ExitCode
|
|
|
|
if ($exitCode -eq 0) {
|
|
|
|
Write-Host 'Installation successful!'
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
Write-Error "Installation failed! Exited with $exitCode."
|
|
|
|
throw
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch {
|
2021-08-13 16:12:24 -07:00
|
|
|
Write-Error "Failed to install Windows PSDK or DDK! $($_.Exception.Message)"
|
2021-04-26 10:27:45 -07:00
|
|
|
throw
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-13 16:12:24 -07:00
|
|
|
# Windows 10 WDK, version 2004
|
|
|
|
InstallWindowsDK 'https://go.microsoft.com/fwlink/?linkid=2128854'
|