Jump to content
danialbulloch

Windows 10 Build Upgrade - 1803 Is Going End of Life!

Recommended Posts

Thanks @Slartibartfast for the start of this script. Slarti's version includes a Windows 7 to 10 upgrade, but I ripped that out because it wasn't needed for my script. I then went on to add a whole lot of checks and balances to the script to make sure it goes smoothly, and alert if it didn't.

The attached script will upgrade a copy of Windows 10 to a newer feature update. All it needs is a copy of the ISO(one for 32 bit and one for 64), placed in LTShare/Transfer folder. You can get the ISO's from Microsoft's Media Creation tool. It emails the initial results to the tech who ran the script, checking for most common failures I could imagine. The script will schedule itself to run again 60 minutes after the initial install finishes(which can take an hour or so after the download finishes). On the second run it will check to see if the upgrade was successful and email the results to the tech who ran the script. The entire process will take upwards to 3 hours, unfortunately. 90% of that time the computer is usable, but I would recommend doing it at night during maintenance hours, as the user will not be warned before the computer is rebooted.

If you are planning on mass updating, you could move the ISOs out to a cloud host, such as azure's storage and download them from there instead, as to not murder the bandwidth on your CWA server.

Download here:

[Edit 2019-10-16] Updated to fix bug with follow up version check.
[Edit 2019-10-17] Script now leaves notes in the script log for actions, instead of just emailing. Also, resend everything doesn't stop on failure.
[Edit 2019-11-20] Added @johnduprey 's powershell to run the install and better check for failures.

 

 

 

Edited by danialbulloch
Script now leaves notes in the script log for actions, instead of just emailing. Also, resend everything doesn't stop on failure.
  • Thanks 1

Share this post


Link to post
Share on other sites

The script has been updated. Mike Jones in the Slack reported an issue that caused the version check to always succeed on the followup run, as well as not giving the old version in the followup results email.

  • Thanks 1

Share this post


Link to post
Share on other sites

Another small update, that I'm not sure makes a difference. This one reported by @jboring. I was clearing out script state before reading it. Didn't seem to break anything, but certainly seems backwards. To be safe I flipped them.

Edited by danialbulloch
  • Thanks 1

Share this post


Link to post
Share on other sites

Thank you Danial.

I can confirm this script works great. The information messages and e-mails it sends along the way are timely and informative. I ran it 200+ times to go from 1803 to 1903.

-Mike

Share this post


Link to post
Share on other sites

Another update to the script. It now leaves an entry in the script log with results, instead of just an email. I also ran into a problem with the script stopping completely if Resend Everything failed on any one part, preventing the followup notification. I turned that to continue on failure, because that's not particularly important to the process. I'm mostly doing the Resend Everything so CWA knows everything that changed due to the upgrade.

  • Thanks 1

Share this post


Link to post
Share on other sites

@danialbulloch is the latest and greatest version at the top?  I started with the scrip supplied by connectwise and modified it to point to a share on our network.  I seem to be having issues using the copy command to transfer the file from the share to the client.  I get the error in the debug that there are permission issues.  

Moving forward I copied the iso to the path on the client manually and ran the script and it behaves like it is running, but never stops and never installs.  I need to debug again and see where it's actually failing.

I am going to take a look at yours and hopefully find my error.

Thanks!!

Share this post


Link to post
Share on other sites

@ViCiouS That is the latest one, I always remove the old version and put the new one in it's place. Your error is likely because the script runs as system on the local computer. Which means that the computer, not any user, must have permissions on the share. I think domain computers will work.

Share this post


Link to post
Share on other sites

I replaced the setup execution with an execute script function that gets the error code and translates it into a human readable message:

https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/windows-setup-command-line-options

$ErrorActionPreference = "SilentlyContinue"

# Disable PDF and XPS features - This might not be necessary but I ran into compatibility issues with those drivers in some rare instances
#Disable-WindowsOptionalFeature -Online -FeatureName Printing-XPSServices-Features | Out-Null
#Disable-WindowsOptionalFeature -Online -FeatureName Printing-PrintToPDFServices-Features | Out-Null

# Remove compatscancache.dat file from failed upgrade
Remove-Item -Path "@LocalPath@\Windows10UpgradeLogs\panther\compatscancache.dat" -Force -ErrorAction SilentlyContinue | Out-Null

# Run the install silently and log files
$install = Start-Process -FilePath "@DriveLetter@:\setup.exe" -ArgumentList "/auto upgrade", "/quiet", "/Compat IgnoreWarning", "/DynamicUpdate disable", "/copylogs @LocalPath@\Windows10UpgradeLogs", "/migratedrivers all" -Wait -PassThru
$hex = "{0:x}" -f $install.ExitCode
$exit_code = "0x$hex"

# Get latest compatibility report XML and list programs
[xml]$compatreport = Get-ChildItem @LocalPath@\Windows10UpgradeLogs\panther\compat* | sort LastWriteTime | select -last 1 | Get-Content
$incompatible_programs = $compatreport.Compatreport.Programs | % {$_.Program.Name}

# Convert hex code to human readable
$message = Switch ($exit_code) {
   "0xC1900210" { "SUCCESS: No compatibility issues detected"; break } 
   "0xC1900101" { "ERROR: Driver compatibility issue detected. https://docs.microsoft.com/en-us/windows/deployment/upgrade/resolution-procedures"; break }
   "0xC1900208" { "ERROR: Compatibility issue detected, unsupported programs:`r`n$incompatible_programs`r`n"; break }
   "0xC1900204" { "ERROR: Migration choice not available." ; break }
   "0xC1900200" { "ERROR: System not compatible with upgrade." ; break }
   "0xC190020E" { "ERROR: Insufficient disk space." ; break }
   "0x80070490" { "ERROR: General Windows Update failure, try the following troubleshooting steps`r`n- Run update troubleshooter`r`n- sfc /scannow`r`n- DISM.exe /Online /Cleanup-image /Restorehealth`r`n - Reset windows update components.`r`n"; break }
   "0xC1800118" { "ERROR: WSUS has downloaded content that it cannot use due to a missing decryption key."; break }
   "0x80090011" { "ERROR: A device driver error occurred during user data migration."; break }
   "0xC7700112" { "ERROR: Failure to complete writing data to the system drive, possibly due to write access failure on the hard disk."; break }
   "0xC1900201" { "ERROR: The system did not pass the minimum requirements to install the update."; break }
   "0x80240017" { "ERROR: The upgrade is unavailable for this edition of Windows."; break }
   "0x80070020" { "ERROR: The existing process cannot access the file because it is being used by another process."; break }
   "0xC1900107" { "ERROR: A cleanup operation from a previous installation attempt is still pending and a system reboot is required in order to continue the upgrade."; break }
   "0x3" { "SUCCESS: The upgrade started, no compatibility issues."; break }
   "0x5" { "ERROR: The compatibility check detected issues that require resolution before the upgrade can continue."; break }
   "0x7" { "ERROR: The installation option (upgrade or data only) was not available."; break }
   "0x0" { "SUCCESSS: Upgrade started."; break }
   default { "WARNING: Unknown exit code."; break }
}

Write-Output "$message (Code: $exit_code)"

 

Edited by johnduprey
  • Thanks 1

Share this post


Link to post
Share on other sites

That's really nice. I'll have to give it a try. If it works well, I'll upload the changes here. I've only had a couple fail, but getting proper reporting on why would be fantastic.

Share this post


Link to post
Share on other sites
On 11/3/2019 at 6:53 PM, johnduprey said:

I replaced the setup execution with an execute script function that gets the error code and translates it into a human readable message:

https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/windows-setup-command-line-options

So I haven't yet debugged it, but when I tried, every workstation that I did gave the unknown exit code error(even though they were successful). The code the script is returning is 0x0.

Edited by danialbulloch

Share this post


Link to post
Share on other sites
On 11/6/2019 at 2:31 PM, danialbulloch said:

So I haven't yet debugged it, but when I tried, every workstation that I did gave the unknown exit code error(even though they were successful). The code the script is returning is 0x0.

0x0 should mean the process ended in success. 

Share this post


Link to post
Share on other sites

Updated my script to include a few more error codes and the option to disable XPS and print to PDF (ran into weird compatibility issues with some systems)

Share this post


Link to post
Share on other sites
On 11/11/2019 at 4:58 PM, Deflect said:

0x0 should mean the process ended in success. 

You are totally right. In the original version of the script John posted it didn't account for 0x0. It does now, I'll update my copy and give it another test.

Share this post


Link to post
Share on other sites

Hey everybody, update is out that not only gives better cleanup on failures, it also does Windows 7! The windows 7 upgrades are barely tested, so please start slow. But so far testing has been 100% successful, even on a machine with 4GB of RAM, a failing harddrive, and a Pentium processor. I figured that was the worst case scenario, and it worked.

Share this post


Link to post
Share on other sites

Great work!

This might help to reduce the amount of disk space required for Windows 7 upgrades, you could use wincdemu to mount the ISO instead of extracting via 7zip
http://wincdemu.sysprogs.org

Just need to add the certificate first to enable install as needs to install driver (attached)

certutil -addstore "TrustedPublisher" sysprogs.cer

WinCDemu-4.1.exe /UNATTENDED

Then to mount is 
batchmnt "@path@\Win10_1909_English_x64.iso" /wait

or

batchmnt "@path@\Win10_1909_English_x64.iso" @driveletter@ /wait

If you didn't specify the drive letter this command will return it
batchmnt /check "@path@\Win10_1909_English_x64.iso"
@path@\Win10_1909_English_x64.iso is mounted to E:

sysprogs.cer

Share this post


Link to post
Share on other sites

@sjones it actually doesn't use more space than is needed for the install anyways. I extract the ISO and then deleted the ISO, freeing up that space. Since the install needs more than 10GB to happen anyways, the temporary 5GB used for the ISO isn't a huge problem. I considered looking at third party ISO mounting software, but decided that the 7zip method is less likely to fail, and doesn't add any software to the system at all.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...