11# Copyright (c) Microsoft Corporation. All rights reserved.
22# Licensed under the MIT license. See LICENSE file in the project root for full license information.
33
4- function Write-Log ([string ] $message , $messageColor = " Green" ) {
5- $currentColor = $Host.UI.RawUI.ForegroundColor
6- $Host.UI.RawUI.ForegroundColor = $messageColor
7- if ($message ) {
8- Write-Output " ... $message "
9- }
10- $Host.UI.RawUI.ForegroundColor = $currentColor
11- }
12-
13- Push-Location
14- try {
15- Write-Log " Downloading the Windows SDK 10.0.14393.795..."
16- Invoke-WebRequest - Method Get - Uri https:// go.microsoft.com / fwlink/ p/ ?LinkId= 838916 - OutFile sdksetup.exe - UseBasicParsing
4+ Write-Host " Downloading Windows SDK 10.0.14393.795..." - ForegroundColor " Green"
5+ Invoke-WebRequest - Method Get - Uri https:// go.microsoft.com / fwlink/ p/ ?LinkId= 838916 - OutFile sdksetup.exe - UseBasicParsing
176
18- Write-Log " Installing the Windows SDK, setup might request elevation please approve."
19- $process = Start-Process - Wait sdksetup.exe - ArgumentList " /quiet" , " /norestart" , " /ceip off" , " /features OptionId.WindowsSoftwareDevelopmentKit" - PassThru
20- Remove-Item sdksetup.exe - Force
7+ Write-Host " Installing Windows SDK, setup might request elevation please approve." - ForegroundColor " Green "
8+ $process = Start-Process - Wait sdksetup.exe - ArgumentList " /quiet" , " /norestart" , " /ceip off" , " /features OptionId.WindowsSoftwareDevelopmentKit" - PassThru
9+ Remove-Item sdksetup.exe - Force
2110
22- if ($process.ExitCode -eq 0 )
23- {
24- Write-Log " Done"
25- }
26- else
27- {
28- Write-Log " Failed (Exit code: $ ( $process.ExitCode ) )" - messageColor " Red"
29- }
11+ if ($process.ExitCode -eq 0 )
12+ {
13+ Write-Host " Done" - ForegroundColor " Green"
3014}
31- finally {
32- Pop-Location
33- }
34-
15+ else
16+ {
17+ Write-Error " Failed to install Windows SDK (Exit code: $ ( $process .ExitCode ) ) "
18+ }
0 commit comments