Worklet: Automox OS Upgrade to Latest Windows10 OS version

i am not sure how to say this…i mean, i am having a moment.

adam…dude, you are killing it. you have saved me sooooo much time. first 1909. now this.

O_o

adam et al., keep it up!

fwiw, if there is some beer/coffee fund that i can venmo/cash app, let me know…i will pony up!!

:see_no_evil::hear_no_evil::speak_no_evil:

5 Likes

I’m curious if there’s a way to run a similar worklet that could mount / install the ISO from a network location rather than downloading one from the internet? I’m not that savvy in powershell, but I’m open to do some tinkering.

That should work, although you might need to tinker with network creds and mapped drives. The worklets run as system and not the currently logged in user, so you can’t rely on any mapped drives or creds from the logged in user.

1 Like

I got this working once I pulled the iso down, I just placed it on a network share then mapped in the powershell code to that location, works pretty good:

You just need to replace: $networkPath with the path you placed the iso in.

Good Luck!!

Jason

Evaluation Code:

if ((Test-Path $iso) -eq $true)

{Remove-Item $iso

}

$osversion = (Get-Item “HKLM:SOFTWARE\Microsoft\Windows NT\CurrentVersion”).GetValue(‘ReleaseID’)

if (($osversion -lt “2004”))

{exit 1

}

else

{exit 0

}

Remediation Code:

<#

.SYNOPSIS

This script will attempt to copy an iso from a network share to a local directory, mount the iso, and run a Windows 10 upgrade command.

.DESCRIPTION

This script may not work on all systems. Modify to fit your needs.

Please test locally and ensure the script runs as intended before automating deployments.

.NOTES

File Name :UpgradeWin10fromISOonNetwork.ps1

Author :Automox

Prerequisite :OS and iso must match in architecture, SKU, and language.

.LINK

http://www.automox.com

#>

############# Change the settings in this block #######################

$networkPath = ‘\isis\PCCommon\Win10\Windows10.iso’

$isoPath = ‘C:\Windows\Temp\Windows10.iso’

$logPath = ‘C:\windows\Temp’

1 Like

Nice, I appreciate the speedy response. Does your above code only mount the ISO or actually run the install? Just from giving it a once-over it appears to just mount it.

I found an applicable code and am trying something similar. I’m currently testing now, will move onto your recommendation if this doesn’t work.

[Evaluation Code]

$osversion = (Get-Item “HKLM:SOFTWARE\Microsoft\Windows NT\CurrentVersion”).GetValue(‘ReleaseID’)

if (($osversion -lt “2004”))
{exit 1
}
else
{exit 0
}
[Remediation Code]

#Variable Decalration
$isoImg = “\[Location]Windows10x64Enterprise2004.iso”
$arguments = “/auto upgrade /quiet /showoobe none /Telemetry disable”

#Mount ISO and Gather Drive Letter
Mount-DiskImage -ImagePath $isoImg -PassThru | Out-Null

#Obtain Drive Letter
$driveletter = (Get-DiskImage $isoImg | Get-Volume).DriveLetter
Write-Host “ISO file has been mounted to drive $driveletter!”

#Launch Windows Upgrade Tool
Start-Process “$($driveLetter):\setup.exe” -ArgumentList $arguments

Yes, it mounts the iso and then runs the install.

I’ve used it to upgrade a few machines per night, usually without fail.

Occasionally I’ll have 1 that won’t upgrade and I’ll just run it manually, but has been working for me pretty good.

Jason

Is there a powershell installation file uploaded to this worklet that it invokes?

Not that I know of no, I worked with Automox techs for like 2 weeks to get it working, I couldn’t get the upgrade from online working so we downloaded the ISO, then they helped adjust the script to point to the network location.

The only powershell that I’m aware of is the script in the worklet.

During testing with the techs, they had me save the worklet into a powershell .ps1 script so we could test, that’s when we figured out how to point to a network location.

Jason

Here is the one @jasonehand and I worked on: Windows 10 Feature Update From Local Server Share

1 Like

Having a few issues with running the ISO from a share, I decided to circle back and try this one again.

It appears to correctly run…goes through the reboot…then fails and reverts back to the previous version (after doing all the Windows is applying Updates junk).

Here are the details from the report:

VERBOSE: Attempting to generate a 64-bit windows 10 iso download link VERBOSE: Attempting to download windows 10 iso to ‘C:\Windows\Temp\Windows10.iso’ WARNING: The Upgrade will commence shortly. Your PC will be rebooted soon. Please save any work you do not want to lose.

I tried to let it it run again and get the following error in activity reports:
Failed to download ISO at path specified. At C:\ProgramData\amagent\execDir603594699\execcmd550507694.ps1:145 char:9 + throw “Failed to download ISO at path specified.” + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : OperationStopped: (Failed to downl…path specified.:String) [], RuntimeException + FullyQualifiedErrorId : Failed to download ISO at path specified. COMMAND TIMED OUT.

I’m kind of at a loss for what to try at this point.

Maybe you could try the update assistant method? It doesnt rely on an ISO. Fewer moving pieces means fewer points of failure.

Replace the last line in the remediation block with this:

1 Like

Doing this prompts this message in the activity report:

The Upgrade will commence shortly. Your PC will be rebooted. Please save any work you do not want to lose.

Since I’m assuming it’s running silently, I’m not 100% if it’s actually upgrading or doing anything, so I’ll let it run tonight and check back in tomorrow morning. I appreciate the speedy recommendation!

1 Like

You can tell if its working by the presence of an Upgrade Assistant process running in the background. The script only calls the executable and exits. It doesnt continue running with the upgrade tool. This does it make a bit more difficult to guage progress.

1 Like

Just wanted to say thanks for this script. Powershell is not my strong suit and I just used this to update the first 100 machines to 20H2 last night with a simple copy & paste. We’ll see how the rest go!

2 Likes

So I spoke too soon. This was working great for a while and has now ceased to function. It seems to coincide with the 1.0-30 agent. I’m now seeing this error in the activity log:

Failed to download ISO at path specified. At C:\ProgramData\amagent\execDir939412927\execcmd817330194.ps1:145 char:9 + throw “Failed to download ISO at path specified.” + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : OperationStopped: (Failed to downl…path specified.:String) [], RuntimeException + FullyQualifiedErrorId : Failed to download ISO at path specified. COMMAND TIMED OUT.

Hmmm, make sure your virus software or firewall has this path whitelisted. We have Sophos for both and I remember going in and whitelisting that entire amagent directory globally. Maybe that will help.

Jason

@askornia
Can you run the ISO manually and it passes the eval checks?
I know my hardware (Lenovo) is still unable to upgrade from 1909 > 2002/20H1 due to issue with a driver for an SSD.

https://support.microsoft.com/en-us/help/4592819/error-when-plugging-in-a-thunderbolt-nvme-ssd

Shouldn’t there be an assignment to $iso at the top of the evaluation? Would it be:
$iso = ‘C:\Windows\Temp\Windows10.iso’

Yup, that line at top worked, thanks!

Jason