Update and Upgrade Windows 10 using PowerShell  

Page 2 of 3 FirstFirst 123 LastLast

  1. Posts : 14
    Windows 10 Home 64-bit
       #10

    Sorry if I was not clear.

    What I want to do is to relegate as much routine computer activity (scans, backups, updates, etc.) as possible to the early hours of the morning while I am asleep. That is why I want it scheduled and completely non-interactive.

    I have written a small script program called Sleepless for Task Scheduler which wakes my laptop from sleep and invokes a custom power plan to prevent sleep/hibernation, dims the screen and runs a quick backup of some important files. It takes only a couple of minutes, but leaves the laptop ready to accept long, unattended, scheduled programs. On nights I want to run such programs, I leave the computer turned on (mains power) and in sleep mode. Sleepless kicks in at 1:50am and I schedule the unattended program/s from 2:00am onwards. The custom power plan stays in place until I click a desktop icon when I am ready, or restart or power off then on. I realise that update restarts may permit unwanted sleep from the normal Balanced power plan, but that could be set up differently.

    I've been doing this for malware scans, Windows Backup and System Image Backup for months, but had not thought of a way to include Windows Update until I saw the potential of PowerShell in this tutorial.

    Does the above background help you to advise whether the PowerShell Windows Update Module:

    a) Can do the job I want non-interactively via Task Scheduler?
    b) Contains all PS cmdlets needed?
    c) Would disable all other WU trigger sources, including WU itself?
    Or, d) Could be realised in better/simpler ways by a different approach?
    The link you supplied referred to the Windows Update MiniTool launched by the WUMT Wrapper Script. Is this a preferred approach or supplement? I do not understand the posts at the end of that link.

    If the PowerShell approach is the way to go, I would still be grateful for any advice you can provide on setting uo the script file for Task Scheduler.

    Apologies for my un-thought-through remarks about Active Hours.

    Thanks.
      My Computer


  2. Posts : 14
    Windows 10 Home 64-bit
       #11

    Hi Kari

    I don't see a cmdlet to disable auto updates. Am I missing something?
      My Computer


  3. Posts : 1
    win 10
       #12

    Force windows updates on several workstations using Powershell


    Hi!
    Is there any way to force Windows updates on a list of computers using Powershell?
    Thank you!
      My Computer


  4. Posts : 317
    Microsoft Windows 10 x64
       #13

    Last version: https://www.powershellgallery.com/packages/PSWindowsUpdate/2.0.0.4

    To install: Install-Module -Name PSWindowsUpdate
    To list commands: Get-Command -Module PSWindowsUpdate

    Code:
     CommandType     Name                                               Version    Source
    -----------     ----                                               -------    ------
    Alias           Download-WindowsUpdate                             2.0.0.4    PSWindowsUpdate
    Alias           Get-WUInstall                                      2.0.0.4    PSWindowsUpdate
    Alias           Get-WUList                                         2.0.0.4    PSWindowsUpdate
    Alias           Hide-WindowsUpdate                                 2.0.0.4    PSWindowsUpdate
    Alias           Install-WindowsUpdate                              2.0.0.4    PSWindowsUpdate
    Alias           Show-WindowsUpdate                                 2.0.0.4    PSWindowsUpdate
    Alias           UnHide-WindowsUpdate                               2.0.0.4    PSWindowsUpdate
    Alias           Uninstall-WindowsUpdate                            2.0.0.4    PSWindowsUpdate
    Cmdlet          Add-WUServiceManager                               2.0.0.4    PSWindowsUpdate
    Cmdlet          Enable-WURemoting                                  2.0.0.4    PSWindowsUpdate
    Cmdlet          Get-WindowsUpdate                                  2.0.0.4    PSWindowsUpdate
    Cmdlet          Get-WUApiVersion                                   2.0.0.4    PSWindowsUpdate
    Cmdlet          Get-WUHistory                                      2.0.0.4    PSWindowsUpdate
    Cmdlet          Get-WUInstallerStatus                              2.0.0.4    PSWindowsUpdate
    Cmdlet          Get-WUJob                                          2.0.0.4    PSWindowsUpdate
    Cmdlet          Get-WULastResults                                  2.0.0.4    PSWindowsUpdate
    Cmdlet          Get-WURebootStatus                                 2.0.0.4    PSWindowsUpdate
    Cmdlet          Get-WUServiceManager                               2.0.0.4    PSWindowsUpdate
    Cmdlet          Get-WUSettings                                     2.0.0.4    PSWindowsUpdate
    Cmdlet          Get-WUTest                                         2.0.0.4    PSWindowsUpdate
    Cmdlet          Invoke-WUJob                                       2.0.0.4    PSWindowsUpdate
    Cmdlet          Remove-WindowsUpdate                               2.0.0.4    PSWindowsUpdate
    Cmdlet          Remove-WUServiceManager                            2.0.0.4    PSWindowsUpdate
    Cmdlet          Set-WUSettings                                     2.0.0.4    PSWindowsUpdate
    Cmdlet          Update-WUModule                                    2.0.0.4    PSWindowsUpdate

    To execute: Get-WindowsUpdate -Install -Verbose
    To list installed updates: Get-WUHistory
      My Computer


  5. Posts : 1,764
    Windows 10 Pro (+ Windows 10 Home VMs for testing)
       #14

    Hmmm... late to the party but this has proven to be very useful already, but quite flaky. Perhaps I'm doing something wrong.

    For example, no amount of issuing the command to hide a Silverlght update actually hid it and it took two goes to hide the accursed KB4023057.

    As another example, whilst Get-WUInstall worked fine first time aound in a PowerShell session, it did nothing the second time round, even though an update was listed as available for install.

    Here's a screenshot:
    Update and Upgrade Windows 10 using PowerShell-pswindowsupdate-flakey.png

    It shows that I listed available updates (shown as 1) then hid one (2) then listed the available updates again (3)... which shows that the update wasn't hidden.

    Next, I chose to install unhidden updates (4) with prompts for each individual install... and nothing happened at all except the prompt returned (5).

    PS - I've only just noticed that PowerShell keeps an MRU history of commands that persists from session to session. Very useful!
      My Computer


  6. Posts : 14
    Windows 10 Home 64-bit
       #15

    Hi RickC
    In your Hide-WUUpdate cmdlet, maybe you need to add the -MicrosoftUpdate parameter before -Confirm. You included it in your first two Get-WUInstall cmdlets. Also to ensure you don't reinstall the Silverlight update use the KB ID parameter, in the final Get-WUInstall - I think I recall hidden updates being included as available??? Also, maybe you should use the -MicrosoftUpdate parameter in your final Get-WUInstall as well. It's in the parameter list.
    See following link re a different Silverlight update, which might still shed some light on update sources:
    https://support.microsoft.com/en-au/...bruary-18-2009
    Hope this helps.
    Old Novice

    - - - Updated - - -

    Hi RickC
    My apologies for the post I sent you yesterday - a bad day: sick family, unexpected interuptions, and too much reliance on my memory. I felt I should revisit today, having done a bit more searching myself.

    1. I assume you are using the Windows Update Service to get updates. I only mention this because the WUS default update source appears to be WindowsUpdate with MicrosoftUpdate an option, both available in the PowerShell Windows Update Module. I am only vaguely aware that some programs, eg Silverlight, provide updates through their specific websites, or through the Microsoft Update Catalog site, and that only some of those may be available also through the PowerShell module options. Because you specified the -MicrosoftUpdate parameter in your initial Get-WUInstall (ListOnly) cmdlet, I wonder if you need to use the same source parameter in your Hide cmdlet to be able to find the update to hide. -MicrosoftUpdate is listed parameter in Get-Help Hide-WUUpdate -Full.

    2. I suspect that the apparent failure to install at your final attempt was again due to the lack of the -MicrosoftUpdate parameter.

    Interested to know if this helps.

    Old Novice
      My Computer


  7. Posts : 1,764
    Windows 10 Pro (+ Windows 10 Home VMs for testing)
       #16

    @Old Novice - Many thanks for your post.

    Further testing confirms - as you suggested - that my lack of experience and insufficient testing was at fault. I now understand the difference between adding the -MicrosoftUpdate parameter and not adding it.

    My issue with Get-WUInstall not working turned out to be my use of Windows Update Blocker. Whilst I had re-enabled Windows Update services, apparently the re-enablement didn't 'take' fully. After I ran Windows Update Blocker and re-enabled a second time, everything is now working as expected.

    I also realised that following the article led to the installation of what is now an old version of PSWindowsUpdate, i.e. 1.5.2.6. On another device I've installed the latest version, i.e. 2.1.1.2 to examine the differences. I note that issuing Get-Command -Module PSWindowsUpdate in 1.5.2.6 shows the CommandTypes as Alias and Function whilst the new version shows Alias and CmdLet instead. Again, this is my lack of experience with PowerShell that I don't yet understand the difference.
    Last edited by RickC; 09 Apr 2019 at 17:27.
      My Computer


  8. Posts : 14
    Windows 10 Home 64-bit
       #17

    Hi RickC
    Pleased your problems are sorted, and glad I could help a bit. I empathise re lack of experience in each of PS, scripting and Win Update. Thanks for mentioning Windows Update Blocker; I'd not heard of it, but looks like I should have, as I've only recently realised the existence of the Windows Update Medic Service. Do you find Blocker reliable in preventing the Medic Service's "interference"?
      My Computer


  9. Posts : 1,764
    Windows 10 Pro (+ Windows 10 Home VMs for testing)
       #18

    Old Novice said:
    Pleased your problems are sorted, and glad I could help a bit.
    PSWindowsUpdate v1.5.2.6 is working fine now but v2.1.1.2 appears buggy. Of course this could still be down to my inexperience but others appear to be having similar issues. For example, I haven't yet been able to get Get-WULastResults to show anything so rely on Get-WUHistory which is fast and provides similar info. It's early days and I'm slowly working my way through Get-Help for each cmdlet.

    Old Novice said:
    Thanks for mentioning Windows Update Blocker; I'd not heard of it, but looks like I should have, as I've only recently realised the existence of the Windows Update Medic Service. Do you find Blocker reliable in preventing the Medic Service's "interference"?
    In my experience (on a number of devices - mine, family and friends), Windows Update Blocker (WUB) has been successful in both blocking Windows Updates and in resisting the Windows Update Medic Service (WaaSMedicSvc).

    There is, however, a downside. Using WUB seems to attract the installation of KB4023057 which installs a Windows Remediation Service (sedsvc) and appears to have a similar function to the Windows Update Medic Service. It seems that if you don't try to block Windows Updates then you often/usually don't get KB4023057 but if you do block Windows Update Medic Service then you get KB4023057 installed outside of the Windows Update mechanism. I've just uninstalled KB4023057 from within Control Panel > Programs and Features and the Windows Remediation Service has gone again (for the time being, at least). (Previous attempts to uninstall KB4023057 haven't been so successful.)

    Another downside of WUB is that Windows Defender updates are also blocked.

    I've already mentioned yet another downside, i.e. that WUB is slow to re-enable Windows Update and its associated services (Delivery Optimization, Update Orchestrator and BITS) or just didn't 'take' the first time I re-enabled them from within WUB. Hopefully the changes to Windows Update in the forthcoming 1903 will render the use of WUB a moot point but, for the moment, it remains my tool of choice.
      My Computer


  10. Posts : 150
    Windows 10 Pro x64 Insider Preview Build 19045.3269
       #19

    Thanks for this interesting post Kari .

    I've run a few tasks as you can see below but are the responses that I'm getting correct??


    Update and Upgrade Windows 10 using PowerShell-image.png

    Thanks for any advice.
      My Computer


 

Tutorial Categories

Update and Upgrade Windows 10 using PowerShell Tutorial Index Network & Sharing Instalation and Upgrade Browsers and Email General Tips Gaming Customization Apps and Features Virtualization BSOD System Security User Accounts Hardware and Drivers Updates and Activation Backup and Restore Performance and Maintenance Mixed Reality Phone


  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 12:57.
Find Us




Windows 10 Forums