55 lines
2.4 KiB
PowerShell
55 lines
2.4 KiB
PowerShell
## Make sure the computer is running Windows 10
|
|
If ( ([System.Environment]::OSVersion.Version).Major -ge 10 ) {
|
|
|
|
## Make sure the endpoint isn't already running 2004
|
|
If ( ([System.Environment]::OSVersion.Version).Build -lt 19041 ) {
|
|
|
|
## Set the directory where the Windows Update Assistant will be downloaded to
|
|
$DOWNLOADS = "${Env:TEMP}"
|
|
|
|
## URL to the 2004 version of the Windows Update Assistant
|
|
## If $URL is already defined when the script is run, just use that value
|
|
If ( !($URL) ) { $URL = 'https://download.microsoft.com/download/8/3/c/83c39dca-2d27-4c24-b98b-0a4d6d921c80/Windows10Upgrade9252.exe' }
|
|
|
|
## Uninstall previous Windows 10 Update Assistant
|
|
If ( Test-Path "${Env:SystemDrive}\Windows10Upgrade\Windows10UpgraderApp.exe" )
|
|
{
|
|
Write-Output "Uninstalling existing Windows 10 Update Assistant"
|
|
Start-Process "${Env:SystemDrive}\Windows10Upgrade\Windows10UpgraderApp.exe" -ArgumentList '/ForceUninstall' -Wait
|
|
}
|
|
|
|
## Create download directory if not using $Env:TEMP
|
|
#If (!( Test-Path $DOWNLOADS ))
|
|
#{
|
|
# Write-Output "Creating "${DOWNLOADS}"
|
|
# New-Item -ItemType Directory -Path $DOWNLOADS
|
|
#}
|
|
|
|
## Download Windows 10 Update Assistant
|
|
$FILENAME = Split-Path $URL -leaf
|
|
If ( Test-Path "${DOWNLOADS}\${FILENAME}" )
|
|
{
|
|
Write-Output "Deleting existing installer: ${DOWNLOADS}\${FILENAME}"
|
|
Remove-Item "${DOWNLOADS}\${FILENAME}" -Force -ErrorAction SilentlyContinue
|
|
}
|
|
Write-Output "Downloading ${URL} to ${DOWNLOADS}\${FILENAME}"
|
|
(New-Object System.Net.WebClient).DownloadFile($URL,"${DOWNLOADS}\${FILENAME}")
|
|
|
|
## Install and run the Windows 10 Update Assistant
|
|
If ( Test-Path "${DOWNLOADS}\${FILENAME}" )
|
|
{
|
|
Write-Output "Launching installer: ${DOWNLOADS}\${FILENAME}"
|
|
Start-Process -FilePath "${DOWNLOADS}\${FILENAME}" -Wait
|
|
}
|
|
|
|
## Delete the downloaded program
|
|
If ( Test-Path "${DOWNLOADS}\${FILENAME}" )
|
|
{
|
|
Write-Output "Deleting installer: ${DOWNLOADS}\${FILENAME}"
|
|
Remove-Item "${DOWNLOADS}\${FILENAME}"
|
|
}
|
|
|
|
} Else { Write-Output "This endpoint is already up to date." }
|
|
|
|
} Else { Write-Output "This endpoint is not running Windows 10." }
|