I just built a job in LanSweeper to silently update Windows 10 from 1909 to 2009 (20H2), the current Feature\Version update. Works great. Installs silently BUT when the install is complete, it restarts the machine.

What Powershell command could I add to this script for it not to restart, but finish when the User restarts? Any help would be much appreciated…

$dir = ‘C:_Windows_FU\packages’
mkdir $dir
$webClient = New-Object System.Net.WebClient
$url = ’
https://go.microsoft.com/fwlink/?LinkID=799445
$file = “$($dir)\Win10Upgrade.exe”
$webClient.DownloadFile($url,$file)
Start-Process -FilePath $file -ArgumentList ‘/quietinstall /skipeula /auto upgrade /copylogs $dir’

Microsoft Windows 10 Pro​

5 Spice ups

Welcome

If you post code, please use the ‘Insert Code’ button. Please and thank you!

codebutton_small.png

Will do. Thank you

1 Spice up

This has nothing to do with PowerShell per se, but with the ’ Win10Upgrade.exe’.

-ArgumentList '/quietinstall /skipeula /auto upgrade /copylogs $dir'

See if it has a’ /NoReboot’ or ’ /SkipFinalize/ parameter.

2 Spice ups

more Info here:

1 Spice up

Using Lansweeper as well to upgrade our Windows 10 computers. I have not tried this, and I am not sure if it’s just for driver installs, but I do recall a switch of /noreboot. Might be worth testing with that to see if it works? Good luck!

1 Spice up

I have done this with success

$ErrorActionPreference = "SilentlyContinue"
$d = "c:\win10exe"
mkdir -p $d
$ComObj = New-Object System.Net.WebClient
$exedl = “https://go.microsoft.com/fwlink/?LinkID=799445"
$exe = “$($d)\Win10Upgrade.exe”
$ComObj.DownloadFile($exedl,$exe)
Start-Process -FilePath $exe -ArgumentList “/quiet /skipeula /auto upgrade /dynamicupdate enable /copylogs $d”

So, this Script installs the Feature update without restarting?

Thanks so much for your input.

Sorry, it does restart when it is ready, it is somewhat necessary for it to do that. When it is doing a major upgrade, it does mess with the OS a ton.

HI I am very new to scripting. How to run this script? Create a file or some sort? Thanks in advance.

@titusovermyer

@spiceuser-mhiuw There are multiple ways of running this PowerShell Script. Here is a couple:

  • You could open a PowerShell console (As Administrator) and paste in and run the commands​.
  • You Could save this in a .ps1 file and call it from PowerShell window using dot source
  • You could deploy the script using a RMM/MDM software that you have.
  • You could deploy it using a Programs like PDQ Deploy or SCCM

Thank you so much @titusovermyer

The OP wrote

" What Powershell command could I add to this script for it not to restart, but finish when the User restarts? Any help would be much appreciated… "

The solution offered here does not solve the requirements.

I have the exact same need and have made a script using the module PSWindowsUpdate. It needs to be installed first with Install-module. and to make that happen you first need NuGet.

Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
Install-Module -force -Name PSWindowsUpdate

I then install all windows updates including FU with:

Install-WindowsUpdate -MicrosoftUpdate -AcceptAll -IgnoreReboot

This works like a charm for all windows updates. And it also installs the FU and says that it is waiting restart.
But here is the problem that I was hoping we could all solve. The FU are installed but not activated (sort of). The user does not see any “restart and update” option. But if i go and check the Windows update status it says “Status: Pending restart”. And if i then click “restart now” it restart and the FU are activated. So that proves the installation happened. It seems that using PSWindowsUpdate module the finalizing does not happen correctly, even though it does the job and tell WU the correct status at the end. All that are missing is the option for the users.

Are there any way I can use Powershell to activate that “restart and update” option?

PS: My script has alot more going on, like logging and showing what updates are updated etc. But the ones shown abowe are the ones that are relevant.

Hi, @chrismullins9988

Have you checked this script?

#      Script: WSUS.ps1
#      Author: Gregory Strike
#     Website: www.GregoryStrike.com
#        Date: 02-19-2010
# Information: This script was adapated from the WUA_SearchDownloadInstall.vbs VBScript from Microsoft.  It uses the
#              Microsoft.Update.Session COM object to query a WSUS server, find applicable updates, and install them.
#
#              WSUS.ps1 is a little less verbose about what it is doing when compared to the orginal VBScript.  The
#              lines exist in the code below to show the same information as the original but are just commented out.
#
#
#              WSUS.ps1 can automatically install applicable updates by passing a Y to the script.  The default
#              behavior is to ask whether or not to install the new updates.
#
#              Syntax:  .\WSUS.ps1 [Install] [Reboot]
#                       Where [Install] is optional and can be "Y", "Yes", "No" or "N"
#                       Whether or not to install the updates automatically.  If Null, the user will be prompted.
#
#                       Where [Reboot] is optional and can be "Y", "Yes", "No" or "N",  This 
#                       If updates require a reboot, whether or not to reboot automatically.  If Null, the user will
#                       be prompted.
 
$UpdateSession = New-Object -Com Microsoft.Update.Session
$UpdateSearcher = $UpdateSession.CreateUpdateSearcher()
 
Write-Host("Searching for applicable updates...") -Fore Green
 
$SearchResult = $UpdateSearcher.Search("IsInstalled=0 and Type='Software'")
 
Write-Host("")
Write-Host("List of applicable items on the machine:") -Fore Green
For ($X = 0; $X -lt $SearchResult.Updates.Count; $X++){
    $Update = $SearchResult.Updates.Item($X)
    Write-Host( ($X + 1).ToString() + "> " + $Update.Title)
}
 
If ($SearchResult.Updates.Count -eq 0) {
    Write-Host("There are no applicable updates.")
    Exit
}
 
#Write-Host("")
#Write-Host("Creating collection of updates to download:") -Fore Green
 
$UpdatesToDownload = New-Object -Com Microsoft.Update.UpdateColl
 
For ($X = 0; $X -lt $SearchResult.Updates.Count; $X++){
    $Update = $SearchResult.Updates.Item($X)
    #Write-Host( ($X + 1).ToString() + "> Adding: " + $Update.Title)
    $Null = $UpdatesToDownload.Add($Update)
}
 
Write-Host("")
Write-Host("Downloading Updates...")  -Fore Green
 
$Downloader = $UpdateSession.CreateUpdateDownloader()
$Downloader.Updates = $UpdatesToDownload
$Null = $Downloader.Download()
 
#Write-Host("")
#Write-Host("List of Downloaded Updates...") -Fore Green
 
$UpdatesToInstall = New-Object -Com Microsoft.Update.UpdateColl
 
For ($X = 0; $X -lt $SearchResult.Updates.Count; $X++){
    $Update = $SearchResult.Updates.Item($X)
    If ($Update.IsDownloaded) {
        #Write-Host( ($X + 1).ToString() + "> " + $Update.Title)
        $Null = $UpdatesToInstall.Add($Update)        
    }
}
 
$Install = [System.String]$Args[0]
$Reboot  = [System.String]$Args[1]
 
If (!$Install){
    $Install = Read-Host("Would you like to install these updates now? (Y/N)")
}
 
If ($Install.ToUpper() -eq "Y" -or $Install.ToUpper() -eq "YES"){
    Write-Host("")
    Write-Host("Installing Updates...") -Fore Green
 
    $Installer = $UpdateSession.CreateUpdateInstaller()
    $Installer.Updates = $UpdatesToInstall
 
    $InstallationResult = $Installer.Install()
 
    Write-Host("")
    Write-Host("List of Updates Installed with Results:") -Fore Green
 
    For ($X = 0; $X -lt $UpdatesToInstall.Count; $X++){
        Write-Host($UpdatesToInstall.Item($X).Title + ": " + $InstallationResult.GetUpdateResult($X).ResultCode)
    }
 
    Write-Host("")
    Write-Host("Installation Result: " + $InstallationResult.ResultCode)
    Write-Host("    Reboot Required: " + $InstallationResult.RebootRequired)
 
    If ($InstallationResult.RebootRequire -eq $True){
        If (!$Reboot){
            $Reboot = Read-Host("Would you like to install these updates now? (Y/N)")
        }
 
        If ($Reboot.ToUpper() -eq "Y" -or $Reboot.ToUpper() -eq "YES"){
            Write-Host("")
            Write-Host("Rebooting...") -Fore Green
            (Get-WMIObject -Class Win32_OperatingSystem).Reboot()
        }
    }
}

https://community.spiceworks.com/scripts/show/1075-download-and-install-updates-with-or-without-reboot

Hi Chrisy!

Thansk for replying. This is a nice script and something I have looked at before. Sadly this is not made to be silent and just wait for the user to restart when they want. And then activate the FU when rebooting.

I’ve been playing with this too, as per:

there is a /noreboot wswitch, which seems to work

...
Start-Process -FilePath $file -ArgumentList '/quietinstall /skipeula /auto upgrade /copylogs $dir' <b>-Wait
</b>**shutdown -a**

With this command the deployment was successful without reboot :wink: