-
Notifications
You must be signed in to change notification settings - Fork 0
/
Windows Feature update.ps1
40 lines (37 loc) · 1.5 KB
/
Windows Feature update.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
Function Install-Windows-10-feature-update {
$dir = 'C:\Temp\WindowsFeatureUpdate\packages'
mkdir $dir -ErrorAction SilentlyContinue | Out-Null
$webClient = New-Object System.Net.WebClient
$url = 'https://go.microsoft.com/fwlink/?LinkID=799445'
$file = "$($dir)\Win10Upgrade.exe"
Write-Host "Downloading Win10Upgrade.exe..." -NoNewline
$webClient.DownloadFile($url, $file)
if ((Test-Path -PathType Leaf $file) -eq $true) {
Write-Host " Successful" -ForegroundColor Green
}
else {
Write-Host " Failed" -ForegroundColor Red
start-sleep -Seconds 4
$trycount = 1
while ($trycount -ne 10 -or (Test-Path -PathType Leaf $file) -eq $true) {
write-host "Attempting download"
$trycount += 1
Write-Host "Try $trycount Downloading Win10Upgrade.exe..." -NoNewline
$webClient.DownloadFile($url, $file)
if ((Test-Path -PathType Leaf $file) -eq $true) {
Write-Host " Successful" -ForegroundColor Green
}
else { Write-Host " Failed" -ForegroundColor Red }
start-sleep -Seconds 4
}
}
if ((Test-Path -PathType Leaf $file) -eq $true) {
Start-Process -FilePath $file -ArgumentList "/quietinstall /skipeula /auto upgrade /copylogs $dir"
write-host "Started Windows Feature Update"
}
else {
Write-Host "Failed to download Win10Upgrade.exe. Aborting installation"
Stop-Transcript
exit 1001
}
}