organization and logic updates
This commit is contained in:
@@ -1,54 +1,50 @@
|
|||||||
## Make sure the computer is running Windows 10
|
## Make sure the computer is running Windows 10
|
||||||
If ( ([System.Environment]::OSVersion.Version).Major -ge 10 ) {
|
If ( IsWindowsVersion -ge "10.0" ) {
|
||||||
|
|
||||||
## Make sure the endpoint isn't already running 2004
|
## Make sure the endpoint isn't already running 2004
|
||||||
If ( ([System.Environment]::OSVersion.Version).Build -lt 19041 ) {
|
If ( IsWindowsBuild -lt 19041 ) {
|
||||||
|
|
||||||
## Set the directory where the Windows Update Assistant will be downloaded to
|
## Set the directory where the Windows Update Assistant will be downloaded to
|
||||||
$DOWNLOADS = "${Env:TEMP}"
|
$DOWNLOADS = $Env:TEMP
|
||||||
|
|
||||||
## URL to the 2004 version of the Windows Update Assistant
|
## URL to the 2004 version of the Windows Update Assistant
|
||||||
## If $URL is already defined when the script is run, just use that value
|
$URL = 'https://download.microsoft.com/download/8/3/c/83c39dca-2d27-4c24-b98b-0a4d6d921c80/Windows10Upgrade9252.exe'
|
||||||
If ( !($URL) ) { $URL = 'https://download.microsoft.com/download/8/3/c/83c39dca-2d27-4c24-b98b-0a4d6d921c80/Windows10Upgrade9252.exe' }
|
|
||||||
|
|
||||||
## Uninstall previous Windows 10 Update Assistant
|
## Uninstall previous Windows 10 Update Assistant
|
||||||
If ( Test-Path "${Env:SystemDrive}\Windows10Upgrade\Windows10UpgraderApp.exe" )
|
If ( Test-Path "${Env:SystemDrive}\Windows10Upgrade\Windows10UpgraderApp.exe" )
|
||||||
{
|
{
|
||||||
Write-Output "Uninstalling existing Windows 10 Update Assistant"
|
Write-Output "Uninstalling existing Windows 10 Update Assistant"
|
||||||
Start-Process "${Env:SystemDrive}\Windows10Upgrade\Windows10UpgraderApp.exe" -ArgumentList '/ForceUninstall' -Wait
|
Try { Start-Process "${Env:SystemDrive}\Windows10Upgrade\Windows10UpgraderApp.exe" -ArgumentList '/ForceUninstall' -Wait }
|
||||||
|
Catch { Write-Output $_.Exception.Message }
|
||||||
}
|
}
|
||||||
|
|
||||||
## 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
|
## Download Windows 10 Update Assistant
|
||||||
$FILENAME = Split-Path $URL -leaf
|
$FILENAME = Split-Path $URL -leaf
|
||||||
If ( Test-Path "${DOWNLOADS}\${FILENAME}" )
|
If ( Test-Path "${DOWNLOADS}\${FILENAME}" )
|
||||||
{
|
{
|
||||||
Write-Output "Deleting existing installer: ${DOWNLOADS}\${FILENAME}"
|
Write-Output "Deleting existing installer: ${DOWNLOADS}\${FILENAME}"
|
||||||
Remove-Item "${DOWNLOADS}\${FILENAME}" -Force -ErrorAction SilentlyContinue
|
Try { Remove-Item "${DOWNLOADS}\${FILENAME}" -Force -ErrorAction SilentlyContinue }
|
||||||
|
Catch { Write-Output $_.Exception.Message }
|
||||||
}
|
}
|
||||||
Write-Output "Downloading ${URL} to ${DOWNLOADS}\${FILENAME}"
|
Write-Output "Downloading ${URL} to ${DOWNLOADS}\${FILENAME}"
|
||||||
(New-Object System.Net.WebClient).DownloadFile($URL,"${DOWNLOADS}\${FILENAME}")
|
Try { (New-Object System.Net.WebClient).DownloadFile($URL,"${DOWNLOADS}\${FILENAME}") }
|
||||||
|
Catch { Write-Output $_.Exception.Message }
|
||||||
|
|
||||||
## Install and run the Windows 10 Update Assistant
|
## Install and run the Windows 10 Update Assistant
|
||||||
If ( Test-Path "${DOWNLOADS}\${FILENAME}" )
|
If ( Test-Path "${DOWNLOADS}\${FILENAME}" )
|
||||||
{
|
{
|
||||||
Write-Output "Launching installer: ${DOWNLOADS}\${FILENAME}"
|
Write-Output "Launching installer: ${DOWNLOADS}\${FILENAME}"
|
||||||
Start-Process -FilePath "${DOWNLOADS}\${FILENAME}" -Wait
|
Try { Start-Process -FilePath "${DOWNLOADS}\${FILENAME}" -Wait }
|
||||||
}
|
Catch { Write-Output $_.Exception.Message }
|
||||||
|
|
||||||
## Delete the downloaded program
|
|
||||||
If ( Test-Path "${DOWNLOADS}\${FILENAME}" )
|
|
||||||
{
|
|
||||||
Write-Output "Deleting installer: ${DOWNLOADS}\${FILENAME}"
|
Write-Output "Deleting installer: ${DOWNLOADS}\${FILENAME}"
|
||||||
Remove-Item "${DOWNLOADS}\${FILENAME}"
|
Try { Remove-Item "${DOWNLOADS}\${FILENAME}" }
|
||||||
|
Catch { Write-Output $_.Exception.Message }
|
||||||
}
|
}
|
||||||
|
Else { Write-Output "${DOWNLOADS}\${FILENAME} does not exist" }
|
||||||
|
|
||||||
} Else { Write-Output "This endpoint is already up to date." }
|
}
|
||||||
|
Else { Write-Output "This endpoint is already up to date." }
|
||||||
|
|
||||||
} Else { Write-Output "This endpoint is not running Windows 10." }
|
}
|
||||||
|
Else { Write-Output "This endpoint is not running Windows 10." }
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ Return [version]$Return.Trim('.')
|
|||||||
}
|
}
|
||||||
|
|
||||||
## Function to compare current Windows version with a supplied version
|
## Function to compare current Windows version with a supplied version
|
||||||
|
## The value supplied must be a string and must include at least 1 decimal
|
||||||
Function IsWindowsVersion
|
Function IsWindowsVersion
|
||||||
{
|
{
|
||||||
param(
|
param(
|
||||||
@@ -78,15 +79,16 @@ switch ($PSCmdlet.ParameterSetName)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
## Function to compare current Windows version with a supplied version
|
## Function to compare current Windows build with a supplied version
|
||||||
|
## The value supplied must be an int
|
||||||
Function IsWindowsBuild
|
Function IsWindowsBuild
|
||||||
{
|
{
|
||||||
param(
|
param(
|
||||||
[Parameter(Mandatory=$true,ParameterSetName='gt')][string]$gt,
|
[Parameter(Mandatory=$true,ParameterSetName='gt')][int]$gt,
|
||||||
[Parameter(Mandatory=$true,ParameterSetName='ge')][string]$ge,
|
[Parameter(Mandatory=$true,ParameterSetName='ge')][int]$ge,
|
||||||
[Parameter(Mandatory=$true,ParameterSetName='lt')][string]$lt,
|
[Parameter(Mandatory=$true,ParameterSetName='lt')][int]$lt,
|
||||||
[Parameter(Mandatory=$true,ParameterSetName='le')][string]$le,
|
[Parameter(Mandatory=$true,ParameterSetName='le')][int]$le,
|
||||||
[Parameter(Mandatory=$true,ParameterSetName='eq')][string]$eq
|
[Parameter(Mandatory=$true,ParameterSetName='eq')][int]$eq
|
||||||
)
|
)
|
||||||
[int]$WindowsBuild = [System.Environment]::OSVersion.Version.Build
|
[int]$WindowsBuild = [System.Environment]::OSVersion.Version.Build
|
||||||
switch ($PSCmdlet.ParameterSetName)
|
switch ($PSCmdlet.ParameterSetName)
|
||||||
|
|||||||
Reference in New Issue
Block a user