Big shoutout to @aescolastico and @Gen123 for contributing to my previous 1903 OS Upgrade Worklet that made this new automatic 1903 feature update possible!
Automox has the functionality to upgrade Windows OS versions natively through any patch policy. Due to some recent changes made by Microsoft, Automox is unable to discover the Windows 10 version 1903 OS upgrade advertised through Windows Update. Automox engineering is working directly with Microsoft to rectify this issue and expect to support this upgrade natively soon.
It is a one-click automatic upgrade without needing to pre-deploy the 1903 .iso image to your devices. This Worklet will automatically build out the download link for 1903 based on your OS’s architecture, download the .iso image to you local system, mount the .iso to a disk drive, and then automatically run the download setup all silently without any user interaction.
The Evaluation and Remediation code for the Worklet is as follows:
Evaluation:
$iso = "C:\programdata\amagent\Windows1903OSUpgrade.iso"
if ((Test-Path $iso) -eq $true)
{Remove-Item $iso
}
$osversion = (get-itemproperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -Name ReleaseId).ReleaseId
if (($osversion -lt "1903"))
{exit 1
}
else
{exit 0
}
Remediation:
$lang = "English"
$locID = "en-US"
$verID = "Windows10ISO"
$skuID = "8829"
$prodID = "1384"
$archID = "IsoX64"
## variables you might not want to change (unless msft changes their schema)
$pgeIDs = @("a8f8f489-4c7f-463a-9ca6-5cff94d8d041", "cfa9e580-a81e-4a4b-a846-7b21bf4e2e5b")
$actIDs = @("getskuinformationbyproductedition", "GetProductDownloadLinksBySku")
$hstParam = "www.microsoft.com"
$segParam = "software-download"
$sdvParam = "2"
## used to spoof a non-windows web request
$userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 Edge/18.18362"
## used to maintain session in subsequent requests
$sessionID = =guid]::NewGuid()
## builds session request url
$uri = "https://www.microsoft.com/" + $locID + "/api/controls/contentinclude/html"
$uri += "?pageId=" + $pgeIDsD0]
$uri += "&host=" + $hstParam
$uri += "&segments=" + $segParam + "," + $verID
$uri += "&query="
$uri += "&action=" + $actIDsD0]
$uri += "&sessionId=" + $sessionID
$uri += "&productEditionId=" + $prodID
$uri += "&sdvParam=" + $sdvParam
## requests user session
Invoke-WebRequest -UserAgent $userAgent -WebSession $session $uri -ErrorAction:Stop -Method:Post -Headers $headers -UseBasicParsing | Out-Null
## builds link request url
$uri = "https://www.microsoft.com/" + $locID + "/api/controls/contentinclude/html"
$uri += "?pageId=" + $pgeIDsD1]
$uri += "&host=" + $hstParam
$uri += "&segments=" + $segParam + "," + $verID
$uri += "&query="
$uri += "&action=" + $actIDsD1]
$uri += "&sessionId=" + $sessionID
$uri += "&skuId=" + $skuID
$uri += "&lang=" + $lang
$uri += "&sdvParam=" + $sdvParam
## requests link data
$response = Invoke-WebRequest -UserAgent $userAgent -WebSession $session $uri -ErrorAction:Stop -Method:Post -Headers $headers -UseBasicParsing
## parses response data
$objs = $response.Links
$objs | Foreach-Object {$_.href = ($_.href).Replace('amp;','')}
$linky = $objs | Select-Object -Property href | Sort-Object -Property href
$link = $linky | Select-Object -ExpandProperty href
## Determine correct link for OS Architecture
$osarch = (Get-WmiObject Win32_OperatingSystem).OSArchitecture
If ($osarch -eq "64-bit") {
$dllink = $link | Where-Object {$_ -match 'x64.iso'}
} elseif ($osarch -eq "32-bit") {
$dllink = $link | Where-Object {$_ -match 'x32.iso'}
}
Write-Output $dllink
Try {
(new-object System.Net.WebClient).DownloadFile("$dllink", "C:\programdata\amagent\Windows1903OSUpgrade.iso") |
Out-file C:\Windows\Temp\output.csv -Append
} Catch {
Write-Error ".iso linked was successfully created but download Failed. Reference c:\windows\temp\output.csv for more information or contact Automox Support"
exit 1
}
#specify path to ISO image
#############Change the settings in this block#######################
$isoImg = "C:\programdata\amagent\Windows1903OSUpgrade.iso"
##############################################################
Mount-DiskImage -ImagePath $isoImg
$letter = (Get-DiskImage $isoImg | Get-Volume).DriveLetter
$dos = ":" ### Unnecessary with changed line below
$drivemount = "$letter" + "$dos"
Set-Location $drivemount
# Required: The drive letter needs to be manually changed to match the value of $driverletter (ex: Y:)
# Optional: /pkey is for a device that needs a product key. Default is disable, remove "#" to enable. (ex: /pkey XXXXX-XXXXX). Not required for install
# Optional: /noreboot is enabled by default. Remove "#" to automatically reboot the device after install is complete
./setup.exe /auto upgrade /quiet #/pkey
The Evaluation code exits with a 1 if a devices OS version is less than 1903 and executes the policy at the scheduled time
Choose the setup.exe arguments you want when it performs the OS update. This is the last line of code in the Remediation block. By Default it is set to do a quiet install and automatically reboot the device to complete the upgrade.
Here is an example of the setup.exe command using the /quiet and /noreboot argument:
Copy to clipboard
.\setup.exe /auto upgrade /quiet /noreboot
That should do it! Be sure to test this on a few devices before deploy to production environment.
Let me know if there are any questions!
- Here is a list of other optional switches you can use in the install command. You just need to add them with a “/’ in front, like the other switches:
- Switch: /showoobe - Action: When /showoobe is set to Full, the end user must interactively complete OOBE. Alternatively, when /showoobe is set to None, OOBE is skipped and components are set to their default settings. Example: setup.exe /auto upgrade /showoobe full
- Switch: /DynamicUpdate - Action: Specifies whether setup will perform Dynamic Update operations (search, download, and install updates). Example: setup.exe /auto upgrade /DynamicUpdate disable
- Switch: /Postoobe Path\setupcomplete.cmd - Action: Injects setupcomplete.cmd file from the specified location. Setupcomplete.cmd is a customized script to perform tasks after the installation completes but before first user login. It is run with System privileges. Example: setup.exe /auto upgrade /postoobe c:\script\setupcomplete.cmd
- Switch: /PBRUpdate - Action: When /PBRUpdate is set to Enable, setup will update or create the PBR partition. Conversely, when /PBRUpdate is set to Disable, setup will not update or create the PBR partition. Example: setup.exe /auto upgrade /PBRupdate disable
- Switch: /migratealldrivers - Action: When /migratealldrivers is set to All, setup will attempt to migrate all drivers as part of the installation. In contrast, when /migratealldrivers is set to None, setup will not migrate any drivers as part of the installation. NOTE: this switch should only be used in testing and test envoriments.It should not be used in production. Example: setup.exe /auto upgrade /migratealldrivers none
- Switch: /installdrivers - Action: Setup will inject all driver.infs found in the specified location during the installation process. Setup will recursively search through all the subfolders of the specified location. Example: setup.exe /auto upgrade /installdrivers c:\myUpgrade\drivers
- Switch: /copylogs - Action: Upon failure, setup will copy or upload compressed logs to the specified location. Please note that the PC and /or user must have permission and network access to the specified file path. This command runs in the system context so may not have permissions to copy to locations that require user permissions. Example: setup.exe /auto upgrade /copylogs \MyShare\UpgradeLogs
- Switch: /Telemetry - Action: When /Telemetry is set to Enable, setup will collect and upload telemetry generated by the installation. However, when /Telemetry is set to Disable, setup will not collect and upload installation – related telemetry. Example: setup.exe /auto upgrade /Telemetry enable
That should do it! Be sure to test this on a few devices before deploy to production environment,
Let me know if there are any questions!