Skip to main content

Automating Windows Updates using PowerShell

Scenario : Windows Server Operating Systems (2008 R2, 2012, 2012 R2, 2016)

Issue : Managing the Windows Updates for multiple servers is a complex task. This can be simplified using PowerShell.

Michal Gajda from Microsoft forum has done a wonderful job by creating custom PowerShell Module for Managing windows updates thru PowerShell.

Link for the Module :

Description : The PSWindowsUpdate module allow you to manage Windows Update on your computer. Module contain set of function to check, download and install or remove update from local machine. Especially useful on machines in core edition like Windows Server 2008 R2 or later.

Steps :

  1. Download : Download the ZIP from above link (
  2. Module can be installed manually by downloading Zip file and extract in two places:
    • %USERPROFILE%\Documents\WindowsPowerShell\Modules
    • %WINDIR%\System32\WindowsPowerShell\v1.0\Modules
  3. Importing the module
    PS > Import-Module PSWindowsUpdate
  4. Enable RemoteExecution on Servers where you are going to Deploy Updates using following PowerShell Command
    Set-ExecutionPolicy RemoteSigned
  5. Invoke following command to Initiate the Installation of Tool on Remote Computer and Install the Latest available updates.
    Invoke-WUInstall -ComputerName -Script {ipmo PSWindowsUpdate; Get-WUInstall -AcceptAll -Force | Out-File -Append C:\PerfLogs\PSWindowsUpdate.log } -Confirm:$false –Verbose

    Above command will copy module files on Remote Computer.
    It will remotely install the PSWindowsUpdate module
    Execute Download and Update the Windows Update command
    It will NOT Restart the Windows Server
    It will save/append log file on the Path C:\PerfLogs\PSWindowsUpdate.log
  6. You can check the Windows Update status after sometime.
  7. Only Issue which I encountered is, it will not produce any log in the Event Log (System) and in Recently Installed updates.
Hope that it will save your valuable time.

Let me know if it helped you and if you have any query in comment.


Popular posts from this blog

Changing Default Port of WSUS Server from 8530 to 80?

Problem : How to change Default Port of WSUS Server from 8530 to 80?Environment : Windows Server 2008 R2 with WSUS 3.0 SP2Solution :1) Go to Start -> RUN -> inetmgr

2) Go to "WSUSAdministration" Site

3) Under "Edit Site", click on "Bindings"

3) Change the port from 8530 to 80, and click OK

4) Open Registry Editor with Start -> RUN -> regedit

5) Goto HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Update Services\Server\Setup

6) Change "Port Number" Value to "80"

7) Goto Command prompt and type following command
cscript "WSUS Installation Location\Update Services\setup\installselfupdateonport80.vbs
"cscript "c:\Program Files\Update Services\setup\installselfupdateonport80.vbs"
C:\Windows\system32>cscript "c:\Program Files\Update Services\setup\installselfupdateonport80.vbs"

Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation. All rights reserved.
SetupSelfupdateTree: Finding th…