Update and Upgrade Windows 10 using PowerShell  

Page 1 of 3 123 LastLast
    Update and Upgrade Windows 10 using PowerShell

    Update and Upgrade Windows 10 using PowerShell

    How to use PowerShell to Update and Upgrade Windows 10
    Published by Category: Installation & Upgrade
    19 Mar 2018
    Designer Media Ltd

    information   Information
    Since its birth in November 2006 PowerShell has evolved to be the chosen tool of network administrators and advanced users alike. Originally a native Windows tool it has since August 2016 been an open source project, spreading its wings to other operating systems, too, starting with Linux.

    According to Wikipedia "PowerShell is a task automation and configuration management framework from Microsoft, consisting of a command-line shell and associated scripting language built on the .NET Framework".

    PowerShell is often falsely thought to be a Command Prompt replacement users reading wrong changes in late Windows 10 versions where PowerShell by default replaced Command Prompt in WIN + X menu; however, both have their own purpose and areas of expertise, both are and will remain integral parts of Windows 10.

    PowerShell should not be feared, it can make administrative and maintenance tasks of a private user even with just a single PC a piece of cake with its logical cmdlets (pronounced command let) and a relatively easy to learn scripting language.

    The cmdlet syntax is VERB-NOUN, always answering the question Do what? Add some parameters and you have a powerful command, like for instance Hide-WUUpdate -KBArticleID "KB1234567" as used later in this tutorial. Easy to understand: Hide (do not show / install) an update with knowledge base ID 1234567.

    This tutorial will show how to take command of Windows Update using PowerShell. Tutorial will cover the basics, feel free to post in this thread if you have any questions.





    Contents

     Click links to jump to any part



    Part One: Install Windows Update Module for PowerShell
    Part Two: Add support for additional Microsoft Products
    Part Three: Check, Install or Hide Windows Updates
    Part Four: Check Update History, Uninstall an Update
    Part Five: Get Help




    Part One

     Install PowerShell Windows Update Module


    1.1)
    Download PSWindowsUpdate.zip from Microsoft TechNet:

    Download

    1.2) Right click the downloaded file, select Extract all:
    Update and Upgrade Windows 10 using PowerShell-image.png

    1.3) Extract ZIP archive to C:\Windows\System32\WindowsPowerShell\v1.0\Modules
    Update and Upgrade Windows 10 using PowerShell-image.png

    1.4) Select Do this for all current items, click Continue:
    Update and Upgrade Windows 10 using PowerShell-image.png

    1.5) Open an elevated (admin) PowerShell, change script execution policy from default Restricted to Unrestricted with following cmdlet:

    Set-ExecutionPolicy Unrestricted -Scope CurrentUser

    Accept with Y. When done, import PSWindowsUpdate module with cmdlet:

    Import-Module PSWindowsUpdate

    Allow PSWindowsUpdate by selecting R (Run). This will be asked twice, separately for two PSWindowsUpdate scripts.
    Update and Upgrade Windows 10 using PowerShell-image.png

    1.6) You can get a list of each available PSWindowsUpdate cmdlet with

    Get-Command -Module PSWindowsUpdate
    Update and Upgrade Windows 10 using PowerShell-image.png





    Part Two

     Add support for additional Microsoft Products


    2.1)
    In Settings App > Update & Security > Windows Update > Advanced Options you can select to get updates to other Microsoft products when updating Windows. To add the same functionality to PSWindowsUpdate run the following cmdlet:

    Add-WUServiceManager -ServiceID 7971f918-a847-4430-9279-4a52d1efe18d
    Update and Upgrade Windows 10 using PowerShell-image.png

    Accept with Y. Notice that the ServiceID is constant string, exactly as shown above

    This step is completely optional; if you do not Windows Update updating other products than Windows, simply skip it.





    Part Three

     Check, Install or Hide Windows Updates


    3.1) To list all Windows and other Microsoft updates, enter the following cmdlet:

    Get-WUInstall -MicrosoftUpdate -ListOnly

    Update and Upgrade Windows 10 using PowerShell-image.png

    In this case there were only updates for Windows available.

    3.2)
    To check available updates and feature upgrades for Windows only (not for additional Microsoft products) enter cmdlet:

    Get-WUInstall -ListOnly
    Update and Upgrade Windows 10 using PowerShell-image.png
    (Screenshot shows cmdlets for steps 3.2 to 3.6)

    3.3) To hide an update you do not want to install you can filter with either full or partial title of an update, or its KB ID

    3.4) Hide update Microsoft Silverlight (KB4013867) using partial title Microsoft:

    Hide-WUUpdate -Title "Microsoft*" -Confirm:$False

    This hides all updates where word Microsoft appears anywhere in update title. In my example case now the Silverlight update was the only one.

    3.5) Hide the same update using KB ID instead of title:

    Hide-WUUpdate -KBArticleID "KB4013867" -Confirm:$False

    3.6) Same filters, title or KB ID can be used to unhide an update adding parameter -HideStatus:$False

    Hide-WUUpdate -Title "Microsoft*" -HideStatus:$False -Confirm:$False

    -- OR --

    Hide-WUUpdate -KBArticleID "KB4013867" -HideStatus:$False -Confirm:$False

    3.7) To install all available, not hidden updates rejecting or accepting each installation manually, use this cmdlet:

    Get-WUInstall

    To also install additional Microsoft product updates:

    Get-WUInstall -MicrosoftUpdate

    3.8) You need to manually accept (Y) or reject (N) each update. When done, if a restart is required you will be asked to accept (Y) or postpone (N) it:
    Update and Upgrade Windows 10 using PowerShell-image.png

    3.9) You can always check if restart is pending and required with

    Get-WURebootStatus
    Update and Upgrade Windows 10 using PowerShell-image.png

    3.10) To automatically accept all updates to be installed add parameter -AcceptAll. To automatically accept a restart if required you can also add -AutoReboot:

    Get-WUInstall -MicrosoftUpdate -AcceptAll -AutoReboot
    Update and Upgrade Windows 10 using PowerShell-image.png

    warning   Warning
    When using -AutoReboot switch, avoid working with sensitive, important documents while PSWindowsUpdate is updating Windows.

    AutoReboot does not give any warning; when updates / upgrades have been initialized Windows will restart without warning causing loss of all unsaved data.


    3.11) Feature upgrades like for instance Windows Insider builds are shown and can be hidden or unhidden exactly as any other update. Notice that for reasons unknown to me feature upgrade sizes are shown wrong, for instance Build 16170 upgrade is under 3 GB download, not almost 150 GB as PSWindowsUpdate shows:
    Update and Upgrade Windows 10 using PowerShell-image.png

    Note   Note
    Notice that when installing a build upgrade with PSWindowsUpdate, restart does not yet finalize upgrade. When you have restarted from PowerShell after PSWindowsUpdate has downloaded and installed build upgrade, it is in fact only initialized, not installed.

    You must restart once more from Start > Power > Update and restart





    Part Four

     Check Update History, Uninstall an Update


    4.1)
    To check your update history use following cmdlet:

    Get-WUHistory

    4.2) Uninstall an update using either its title or KB ID as shown in steps 3.4 & 3.5:

    Get-WUUninstall -KBArticleID "KB4013867" -Confirm:$False

    -- OR --

    Get-WUUninstall -Title "Microsoft Silverlight*" -Confirm:$False
    Update and Upgrade Windows 10 using PowerShell-image.png





    Part Five

     Get Help


    5.1)
    To get help, correct command syntax and examples about usage of a cmdlet, normal PowerShell help is available.

    For instance to get help with Hide-WUUpdate cmdlet enter the following cmdlet:

    Get-Help Hide-WUUpdate

    Notice that when Get-Help is run first time it needs to be updated (cmdlet Update-Help run). Accept it with Y, this is one time only process not required with further use of Get-Help cmdlet:
    Update and Upgrade Windows 10 using PowerShell-image.png


    That's it geeks! Please post all your concerns, questions and issues with PSWindowsUpdate in this thread.

    Kari







  1. Posts : 17,661
    Windows 10 Pro
       #1

    Just showing how practical this is. Using -AcceptAll and -Autoreboot switches, I run all updates including Insider Build 16176 upgrade with one command, updating and upgrading a Windows 10 tablet, which then restarts automatically applying the updates and build upgrade:
    Update and Upgrade Windows 10 using PowerShell-image.png

    Only minor glitch is, as told in step 3.11, that for some reason PSWindowsUpdate shows feature / build upgrade size completely wrong. In screenshot above you can see that PSWindowsUpdate thinks the 16176 build upgrade is 85 GB when it in reality is under 3 GB.
      My Computer


  2. Posts : 15,426
    Windows10
       #2

    One observation I have is that I have had to disable driver updates using gpedit.msc (Pro N) as the latest broadcom wifi drives was causing BSODs, but when I run get-wuinstall, it still lists the driver and I have to decline it each time.

    Is there a way around this?
      My Computer


  3. Posts : 17,661
    Windows 10 Pro
    Thread Starter
       #3

    cereberus said:
    Is there a way around this?
    Have you hidden it with Hide-WUUpdate?
      My Computer


  4. Posts : 17,661
    Windows 10 Pro
    Thread Starter
       #4

    I just love the simplicity of PSWindowsUpdate! Fresh clean install of version 1703, run the updates, get coffee and come back to updated Windows 10.
    Update and Upgrade Windows 10 using PowerShell-image.png
      My Computer


  5. Posts : 15,426
    Windows10
       #5

    Kari said:
    Have you hidden it with Hide-WUUpdate?
    I will try that.
      My Computer


  6. Posts : 17,661
    Windows 10 Pro
    Thread Starter
       #6

    cereberus said:
    I will try that.
    See steps 3.3 through 3.6 for how to hide an update. It should work.
      My Computer


  7. Posts : 15,426
    Windows10
       #7

    Kari said:
    See steps 3.3 through 3.6 for how to hide an update. It should work.
    Thanks
      My Computer


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

    Hi Kari

    I've just didcovered this interesting tutorial. Thank you. It may be just what I am after, but I'm not experienced enough to be sure, either in scripting or Power Shell, so would welcome guidance please.

    My PC is a Lenovo laptop running Win 10 Home, all updates installed, and Active Hours set for updates.

    I want to be able to check for updates, download and install, including restarts when needed. No frills or exceptions envisaged. Would PSWindowsUpdate be usable or adaptable to run from Task Scheduler completely unattended? I already do malware scans and backups this way.

    If that could be done, I assume that scheduling would obviate the need for Active Hours. Correct?

    The following is how I think I should use the tutorial. Please advise if I am on the wrong track or unduly optomistic, etc.

    The cmdlets to use in Task Scheduler actions (unattended) Should only be those which are non-interactive and download and should install all updates and restarts, and I should combine them into a separately titled script file. True?

    Part 1.

    1.1 through 1.6: Follow tutorial to install module.

    1.4: Will folder access be denied if signed in as Administrator? If so can I avoid 1.4?

    1.5: Is this related to Group Policy, which I know is N/A in Home Edition? The cmdlet looks to be interactive. If so, is there a non-interactive alternative?

    1.6: I assume this is a utility to use if/when needed and not routinely. True?

    Part 2.

    2.1: Option to include other Microsoft products. This is my current setting in the Windows Settings App. I I would like to retain this setting but the cmdlet seems to be interactive. How can I handle it?

    Part 3.

    3.1 through 3.9 appear to be cmdlets to list, check or hide specific updates, so they would not be used when installing All unattended. True?

    3.10: Needs to be included - AcceptAll AutoReboot. True?
    As 3.10 appears to contain the final cmdlet needed, I assume the additional restart needed for build upgrades could be manual when I next visit the computer. True?

    Part 4.
    Part 5.

    Both parts seem to be unnecessary for Task Scheduler. True?

    Thank you for your patience in wading through this.

    Old Novice
      My Computer


  9. Posts : 5,478
    2004
       #9

    Old Novice said:
    If that could be done, I assume that scheduling would obviate the need for Active Hours. Correct?
    Surely you would be replacing MS active hours with your own active hours?

    I think you would need to block updates so they didn't interfere (see here: Stop Windows 10 Updates Properly and Completely Solved - Windows 10 Forums) and then assuming your scheduled task was using the -AcceptAll switch so as not involve any user input (otherwise why not run it interactively) you'd end up back where you started - all updates running at a specific time defined by you.


    Perhaps I'm misunderstanding what you want to do.
      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 05:20.
Find Us




Windows 10 Forums