## Make sure the computer is running Windows 10
If ( IsWindowsVersion -ge "10.0" ) {

    ## Make sure the endpoint isn't already running the version we're installing
    If ( IsWindowsBuild -lt 19043 ) {
        
        ## Set the directory where the Windows Update Assistant will be downloaded to
        $DOWNLOADS = $Env:TEMP

        ## URL to the Windows Update Assistant
        $URL = 'https://download.microsoft.com/download/4/1/0/410b6165-c770-4944-b074-ecbe9461034c/Windows10Upgrade9252.exe'

        ## Uninstall previous Windows 10 Update Assistant
        If ( Test-Path "${Env:SystemDrive}\Windows10Upgrade\Windows10UpgraderApp.exe" )
        {
            LogMsg "Uninstalling existing Windows 10 Update Assistant"
            Try { Start-Process "${Env:SystemDrive}\Windows10Upgrade\Windows10UpgraderApp.exe" -ArgumentList '/ForceUninstall' -Wait }
            Catch { LogMsg $_.Exception.Message }
        }

        ## Download Windows 10 Update Assistant
        $FILENAME = Split-Path $URL -leaf
        If ( Test-Path "${DOWNLOADS}\${FILENAME}" )
        {
            LogMsg "Deleting existing installer: ${DOWNLOADS}\${FILENAME}"
            Try { Remove-Item "${DOWNLOADS}\${FILENAME}" -Force -ErrorAction SilentlyContinue }
            Catch { LogMsg $_.Exception.Message }
        }
        LogMsg "Downloading ${URL} to ${DOWNLOADS}\${FILENAME}"
        Try { (New-Object System.Net.WebClient).DownloadFile($URL,"${DOWNLOADS}\${FILENAME}") }
        Catch { LogMsg $_.Exception.Message }

        ## Install and run the Windows 10 Update Assistant
        If ( Test-Path "${DOWNLOADS}\${FILENAME}" )
        {
            LogMsg "Launching installer: ${DOWNLOADS}\${FILENAME}"
            Try { Start-Process -FilePath "${DOWNLOADS}\${FILENAME}" }
            Catch { LogMsg $_.Exception.Message }
        }
        Else { LogMsg "${DOWNLOADS}\${FILENAME} does not exist" }

    }
    Else { LogMsg "This endpoint is already up to date." }

}
Else { LogMsg "This endpoint is not running Windows 10." }
