Update and Upgrade Windows 10 using PowerShell

    Update and Upgrade Windows 10 using PowerShell

    How to use PowerShell to Update and Upgrade Windows10
    Published by Category: Installation & Upgrade
    18 Aug 2017
    Designer Media Ltd

    Published by


    Kari's Avatar
    PhD in Malt Based Liquids


    Location: A Finnish expat in Germany
    Posts: 13,096

    Show Printable Version 


    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.





    Update and Upgrade Windows 10 using PowerShell Contents Update and Upgrade Windows 10 using PowerShell
     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




    Update and Upgrade Windows 10 using PowerShell Part One Update and Upgrade Windows 10 using PowerShell
     Install PowerShell Windows Update Module

    1.1)
    Download PSWindowsUpdate.zip from Microsoft TechNet:

    download

    1.2) Right click the downloaded file, select Extract all:
    Name:  image.png
Views: 11048
Size:  29.9 KB

    1.3) Extract ZIP archive to C:\Windows\System32\WindowsPowerShell\v1.0\Modules
    Name:  image.png
Views: 11014
Size:  22.2 KB

    1.4) Select Do this for all current items, click Continue:
    Name:  image.png
Views: 10991
Size:  89.5 KB

    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.
    Click image for larger version. 

Name:	image.png 
Views:	328 
Size:	730.5 KB 
ID:	138084

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

    Get-Command -Module PSWindowsUpdate
    Click image for larger version. 

Name:	image.png 
Views:	396 
Size:	357.3 KB 
ID:	129401





    Update and Upgrade Windows 10 using PowerShell Part Two Update and Upgrade Windows 10 using PowerShell
     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
    Click image for larger version. 

Name:	image.png 
Views:	146 
Size:	235.6 KB 
ID:	129404

    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.





    Update and Upgrade Windows 10 using PowerShell Part Three Update and Upgrade Windows 10 using PowerShell
     Check, Install or Hide Windows Updates

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

    Get-WUInstall -MicrosoftUpdate -ListOnly

    Click image for larger version. 

Name:	image.png 
Views:	123 
Size:	176.6 KB 
ID:	129408

    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
    Name:  image.png
Views: 11093
Size:  430.2 KB
    (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:
    Click image for larger version. 

Name:	image.png 
Views:	231 
Size:	848.2 KB 
ID:	129411

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

    Get-WURebootStatus
    Name:  image.png
Views: 10990
Size:  38.7 KB

    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
    Click image for larger version. 

Name:	image.png 
Views:	193 
Size:	320.5 KB 
ID:	129413

    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:
    Click image for larger version. 

Name:	image.png 
Views:	99 
Size:	118.1 KB 
ID:	129414

    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





    Update and Upgrade Windows 10 using PowerShell Part Four Update and Upgrade Windows 10 using PowerShell
     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
    Click image for larger version. 

Name:	image.png 
Views:	95 
Size:	267.1 KB 
ID:	129415





    Update and Upgrade Windows 10 using PowerShell Part Five Update and Upgrade Windows 10 using PowerShell
     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:
    Click image for larger version. 

Name:	image.png 
Views:	239 
Size:	737.8 KB 
ID:	129416


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

    Kari



  1.    15 Apr 2017 #1
    Join Date : Oct 2013
    A Finnish expat in Germany
    Posts : 13,096
    Windows 10 Pro

    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:
    Click image for larger version. 

Name:	image.png 
Views:	116 
Size:	1.05 MB 
ID:	130195

    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 ComputerSystem Spec
  2.    15 Apr 2017 #2
    Join Date : Dec 2015
    Posts : 6,348
    Windows10

    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 ComputerSystem Spec
  3.    15 Apr 2017 #3
    Join Date : Oct 2013
    A Finnish expat in Germany
    Posts : 13,096
    Windows 10 Pro
    Thread Starter

    Quote Originally Posted by cereberus View Post
    Is there a way around this?
    Have you hidden it with Hide-WUUpdate?
      My ComputerSystem Spec
  4.    18 Apr 2017 #4
    Join Date : Oct 2013
    A Finnish expat in Germany
    Posts : 13,096
    Windows 10 Pro
    Thread Starter

    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.
    Click image for larger version. 

Name:	image.png 
Views:	128 
Size:	53.9 KB 
ID:	130731
      My ComputerSystem Spec
  5.    18 Apr 2017 #5
    Join Date : Dec 2015
    Posts : 6,348
    Windows10

    Quote Originally Posted by Kari View Post
    Have you hidden it with Hide-WUUpdate?
    I will try that.
      My ComputerSystem Spec
  6.    18 Apr 2017 #6
    Join Date : Oct 2013
    A Finnish expat in Germany
    Posts : 13,096
    Windows 10 Pro
    Thread Starter

    Quote Originally Posted by cereberus View Post
    I will try that.
    See steps 3.3 through 3.6 for how to hide an update. It should work.
      My ComputerSystem Spec
  7.    18 Apr 2017 #7
    Join Date : Dec 2015
    Posts : 6,348
    Windows10

    Quote Originally Posted by Kari View Post
    See steps 3.3 through 3.6 for how to hide an update. It should work.
    Thanks
      My ComputerSystem Spec

 


Similar Threads
Tutorial Category
Solved Windows PowerShell acting weird?
Hello, After updating from insider to 15063 and 15063.11 RTM powershell seems to be showing random symbols, but when I try to copy paste these symbols somewhere else they show up as normal text. In powershell I see this: 127506 After...
General Support
[Newbie]How can i update windows from CLI (powershell)
coming from linux (was using LXDE on arch)i have been used to the terminal and using the UI for everything is very unconformable (and slow)
Windows Updates and Activation
BitsTransfer using https on powershell 2.0 and windows 7
Hi, I have a question about using Bitstransfer on powershell in order to download data via https. The following code works well on powershell 5.5 of windows 10 while it does not work on powershell 2.2 of windows 7. In particular, the problem...
Network and Sharing
After Windows 10 upgrade getting PowerShell has stopped working error
After I updated to Windows 10 I get multiple "Powershell has stopped working" errors. How do I get rid of this error. Things I have tried: Downloaded Malwarebytes and ran scan - did not fix issue. Downloaded RegCurePro and ran scan - did not...
Windows Updates and Activation
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 16:00.
Find Us
Twitter Facebook Google+ Ten Forums iOS App Ten Forums Android App



Windows 10 Forums