From 181f3e733b0a57296565128dc81a7cd6df3a041f Mon Sep 17 00:00:00 2001 From: Chan9390 Date: Wed, 26 Jul 2017 14:41:37 +0530 Subject: [PATCH] Moving dotnet installation to Autounattend.xml --- answer_files/2008_r2/Autounattend.xml | 5 +++++ scripts/installs/install_dotnet45.ps1 | 23 +++++++++++++++++++++++ windows_2008_r2.json | 2 ++ 3 files changed, 30 insertions(+) create mode 100644 scripts/installs/install_dotnet45.ps1 diff --git a/answer_files/2008_r2/Autounattend.xml b/answer_files/2008_r2/Autounattend.xml index 0c0e1e8..9cc06ce 100644 --- a/answer_files/2008_r2/Autounattend.xml +++ b/answer_files/2008_r2/Autounattend.xml @@ -259,6 +259,11 @@ cmd.exe /c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File a:\install_netfx.ps1 -AutoStart Install .NET 4.0 27 + + + cmd.exe /c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File a:\install-dotnet-451.ps1 -AutoStart + 98 + Install .NET 4.5.1 diff --git a/scripts/installs/install_dotnet45.ps1 b/scripts/installs/install_dotnet45.ps1 new file mode 100644 index 0000000..8bcd188 --- /dev/null +++ b/scripts/installs/install_dotnet45.ps1 @@ -0,0 +1,23 @@ +$Logfile = "C:\Windows\Temp\dotnet-install.log" +function LogWrite { + Param ([string]$logstring) + $now = Get-Date -format s + Add-Content $Logfile -value "$now $logstring" + Write-Host $logstring +} + +LogWrite "Downloading dotNet 4.5.1" +try { + (New-Object System.Net.WebClient).DownloadFile('http://download.microsoft.com/download/1/6/7/167F0D79-9317-48AE-AEDB-17120579F8E2/NDP451-KB2858728-x86-x64-AllOS-ENU.exe', 'C:\Windows\Temp\dotnet.exe') +} catch { + LogWrite $_.Exception | Format-List -force + LogWrite "Failed to download file." +} + +LogWrite "Starting installation process..." +try { + Start-Process -FilePath "C:\Windows\Temp\dotnet.exe" -ArgumentList "/I /q /norestart" -Wait -PassThru +} catch { + LogWrite $_.Exception | Format-List -force + LogWrite "Exception during install process." +} diff --git a/windows_2008_r2.json b/windows_2008_r2.json index 7ebbbf4..b09678c 100644 --- a/windows_2008_r2.json +++ b/windows_2008_r2.json @@ -21,6 +21,7 @@ "./scripts/configs/win-updates.ps1", "./scripts/installs/openssh.ps1", "./scripts/installs/install_netfx.ps1", + "./scripts/installs/install_dotnet45.ps1", "./resources/certs/oracle-cert.cer", "./resources/certs/gdig2.crt", "./resources/certs/comodorsadomainvalidationsecureserverca.crt", @@ -64,6 +65,7 @@ "./scripts/configs/win-updates.ps1", "./scripts/installs/openssh.ps1", "./scripts/installs/install_netfx.ps1", + "./scripts/installs/install_dotnet45.ps1", "./resources/certs/oracle-cert.cer", "./resources/certs/gdig2.crt", "./resources/certs/comodorsadomainvalidationsecureserverca.crt",