Files
management-scripts/Start-Windows10UpdateAssistant.ps1
T

51 lines
2.2 KiB
PowerShell
Raw Normal View History

2019-11-11 19:22:39 -05:00
## Make sure the computer is running Windows 10
2020-09-09 16:59:40 -04:00
If ( IsWindowsVersion -ge "10.0" ) {
2019-11-11 19:22:39 -05:00
2020-08-18 16:20:20 -04:00
## Make sure the endpoint isn't already running 2004
2021-05-21 12:19:34 -04:00
If ( IsWindowsBuild -lt 19042 ) {
2019-11-11 19:22:39 -05:00
## Set the directory where the Windows Update Assistant will be downloaded to
2020-09-09 16:59:40 -04:00
$DOWNLOADS = $Env:TEMP
2019-11-11 19:22:39 -05:00
2020-08-18 16:20:20 -04:00
## URL to the 2004 version of the Windows Update Assistant
2021-05-21 12:19:34 -04:00
$URL = 'https://download.microsoft.com/download/3/0/1/301147e7-e3d3-467e-a9eb-003a72840887/Windows10Upgrade9252.exe'
2019-11-11 19:22:39 -05:00
## Uninstall previous Windows 10 Update Assistant
If ( Test-Path "${Env:SystemDrive}\Windows10Upgrade\Windows10UpgraderApp.exe" )
2020-05-22 14:35:46 -04:00
{
Write-Output "Uninstalling existing Windows 10 Update Assistant"
2020-09-09 16:59:40 -04:00
Try { Start-Process "${Env:SystemDrive}\Windows10Upgrade\Windows10UpgraderApp.exe" -ArgumentList '/ForceUninstall' -Wait }
Catch { Write-Output $_.Exception.Message }
2020-05-22 14:35:46 -04:00
}
2019-11-11 19:22:39 -05:00
## Download Windows 10 Update Assistant
$FILENAME = Split-Path $URL -leaf
2020-05-22 14:35:46 -04:00
If ( Test-Path "${DOWNLOADS}\${FILENAME}" )
{
Write-Output "Deleting existing installer: ${DOWNLOADS}\${FILENAME}"
2020-09-09 16:59:40 -04:00
Try { Remove-Item "${DOWNLOADS}\${FILENAME}" -Force -ErrorAction SilentlyContinue }
Catch { Write-Output $_.Exception.Message }
2020-05-22 14:35:46 -04:00
}
Write-Output "Downloading ${URL} to ${DOWNLOADS}\${FILENAME}"
2020-09-09 16:59:40 -04:00
Try { (New-Object System.Net.WebClient).DownloadFile($URL,"${DOWNLOADS}\${FILENAME}") }
Catch { Write-Output $_.Exception.Message }
2019-11-11 19:22:39 -05:00
## Install and run the Windows 10 Update Assistant
If ( Test-Path "${DOWNLOADS}\${FILENAME}" )
2020-05-22 14:35:46 -04:00
{
Write-Output "Launching installer: ${DOWNLOADS}\${FILENAME}"
2020-09-09 16:59:40 -04:00
Try { Start-Process -FilePath "${DOWNLOADS}\${FILENAME}" -Wait }
Catch { Write-Output $_.Exception.Message }
2019-11-11 19:22:39 -05:00
2020-05-22 14:35:46 -04:00
Write-Output "Deleting installer: ${DOWNLOADS}\${FILENAME}"
2020-09-09 16:59:40 -04:00
Try { Remove-Item "${DOWNLOADS}\${FILENAME}" }
Catch { Write-Output $_.Exception.Message }
2020-05-22 14:35:46 -04:00
}
2020-09-09 16:59:40 -04:00
Else { Write-Output "${DOWNLOADS}\${FILENAME} does not exist" }
2019-11-11 19:22:39 -05:00
2020-09-09 16:59:40 -04:00
}
Else { Write-Output "This endpoint is already up to date." }
2019-11-11 19:22:39 -05:00
2020-09-09 16:59:40 -04:00
}
Else { Write-Output "This endpoint is not running Windows 10." }