Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Upcoming SlideShare
What to Upload to SlideShare
What to Upload to SlideShare
Loading in …3
×
1 of 34

HOWTO: Powershell Script to Install Windows Updates Remotely

0

Share

Download to read offline

It is very convenient to use a special PowerShell script- PSWindowsUpdate to install Windows updates remotely from the command line on a separate computer. The PSWindowsUpdate module is not built into Windows and it is a third-party module available in the Technet Script Gallery. PSWindowsUpdate allows administrators to remotely check for updates on computers and workstations, install, remove and hide certain updates. The PSWindowsUpdate module is especially valuable when used to manage Windows updates in the Core editions of Windows Server, which do not have a graphical interface, as well as when setting up a Windows image in audit mode.

In this article, I show a Powershell script to install Windows Updates remotely also you will find another module which helps to get a list of all the missing Windows updates.

Related Books

Free with a 30 day trial from Scribd

See all

Related Audiobooks

Free with a 30 day trial from Scribd

See all

HOWTO: Powershell Script to Install Windows Updates Remotely

  1. 1. HOWTO: Powershell Script to Install Windows Updates Remotely © Action1 Corporation. All rights reserved.
  2. 2. It is very convenient to use a special PowerShell script- PSWindowsUpdate to install Windows updates remotely from the command line on a separate computer. The PSWindowsUpdate module is not built into Windows and it is a third-party module available in the Technet Script Gallery. PSWindowsUpdate allows administrators to remotely check for updates on computers and workstations, install, remove and hide certain updates. action1.com
  3. 3. The PSWindowsUpdate module is especially valuable when used to manage Windows updates in the Core editions of Windows Server, which do not have a graphical interface, as well as when setting up a Windows image in audit mode. In this presentation, I show a Powershell script to install Windows Updates remotely also you will find another module which helps to get a list of all the missing Windows updates. action1.com
  4. 4. 1. Installing the Update Management Module PsWindowsUpdate If you have Windows 10 installed, you can install the PSWindowsUpdate module from the online repository via the Package Manager PackageManagement with just one command:Install-Module -Name PSWindowsUpdate Manually: action1.com
  5. 5. 1. Installing the Update Management Module PsWindowsUpdate If you have an older version of Windows (Windows 7 / 8.1 / Windows Server 2008 R2 / 2012 R2) or do not have direct Internet access, you can install the PSWindowsUpdate module manually. This module can be installed on any supported version of Windows, starting with Vista / Windows Server 2008 with PowerShell 2.0 installed (but PoSh 3.0 and higher is recommended). Manually: action1.com
  6. 6. 1. Installing the Update Management Module PsWindowsUpdate - Download the latest version of the PSWindowsUpdate module from the page: https://gallery.technet.microsoft.com/scriptcenter/2d191bcd- 3308-4edd-9de2-88dff796b0bc and unlock the downloaded file. Manually: action1.com
  7. 7. Manually: action1.com
  8. 8. 1. Installing the Update Management Module PsWindowsUpdate - Unpack the archive with the module into one of the% USERPROFILE% Documents WindowsPowerShell Modules or% WINDIR% System32 WindowsPowerShell v1.0 Modules directories (using the module permanently is the best option). - Allow script execution: Set-ExecutionPolicy RemoteSigned - Now you can import a module into your PowerShell session: Import-Module PSWindowsUpdate Manually: action1.com
  9. 9. Manually: action1.com
  10. 10. 1. Installing the Update Management Module PsWindowsUpdate Note. In Windows 7 / Server 2008 R2, when importing a PSWindowsUpdate module, you may encounter an error like the following: The name “Unblock-File” is not recognized as the name of the cmdlet. The point is that the module uses some functions that appeared only in PowerShell 3.0. To use these functions, you will have to update PowerShell, or manually remove the line | Unblock-File from the PSWindowsUpdate.psm1 file. Manually: action1.com
  11. 11. 1. Installing the Update Management Module PsWindowsUpdate If you installed the Windows Update Management Module on your computer, you can install it remotely on other computers and / or servers. Use this script to copy the module to the two specified remote servers: Manually: action1.com
  12. 12. 1. Installing the Update Management Module PsWindowsUpdate $ Targets = "Server1", "Server2" Update-WUModule - LocalPSWUSource "C: Windows system32 WindowsPowerShell v1.0 Modules PSWindowsUpdate" - ComputerName $ Targets Invoke-Command -ComputerName $ Targets -ScriptBlock {Add- Content $ Env: WINDIR system32 WindowsPowerShell v1.0 profile.ps1 "` `nImport-Module PSWindowsUpdate"} Manually: action1.com
  13. 13. 2. Overview Module PSWindowsUpdate Commands The list of available cmdlets for the module can be displayed as:get-command-module PSWindowsUpdate Briefly describe the purpose of the module commands: Get-WindowsUpdate - an alias for Get-WUList. Hide-WindowsUpdate - alias for Hide-WUUpdate. Install-WindowsUpdate - alias for Get-WUInstall. Uninstall-WindowsUpdate - alias for Get-WUUninstall. Manually: action1.com
  14. 14. 2. Overview Module PSWindowsUpdate Commands Add-WUOfflineSync - the function allows you to install updates from the local cache using the file wsusscan.cab or wsusscn2.cab. Add-WUServiceManager - register the update server on a computer. Get-WUHistory - displays a list of installed updates. Manually: action1.com
  15. 15. 2. Overview Module PSWindowsUpdate Commands Get-WUInstall is the main cmdlet of the PSWindowsUpdate module. Allows you to download and install updates from the server WSUS or Microsoft Update. Allows you to select categories of updates, specific updates and specify the rules for restarting the computer when installing updates. Get-WUInstallerStatus - check the status of the Windows Installer service. Manually: action1.com
  16. 16. 2. Overview Module PSWindowsUpdate Commands Get-WURebootStatus - allows you to check whether a reboot is necessary to apply a specific update. Get-WUList - lists the updates that meet the specified criteria, allows you to find and install the desired update. Get-WUServiceManager - check for update sources. Get-WUUninstall - cmdlet allows you to remove a specific update by KB ID. Manually: action1.com
  17. 17. 2. Overview Module PSWindowsUpdate Commands Hide-WUUpdate - allows you to hide certain updates from the installation. Invoke-WUInstall - manage remote installation of updates. Remove-WUOfflineSync - remove offline scan source. Remove-WUServiceManager - remove update server. Manually: action1.com
  18. 18. Manually: action1.com
  19. 19. 3. Get a List of Available Updates for the Computer List the available updates for your computer on the update server:Get-WUInstall -ListOnly To check the list of available updates on a remote computer, run: Get-WUList –ComputerName server2 You can check where your Windows should get updates from. Run the command: Get-WUServiceManager ServiceID IsManaged IsDefault Name Manually: action1.com
  20. 20. Manually: action1.com
  21. 21. 3. Get a List of Available Updates for the Computer As you can see, the computer is configured to receive updates from the local WSUS and Windows Update service. If you want to scan your computer on Microsoft Update servers (besides Windows updates, these servers contain Office updates and other products) on the Internet, run the following command: Get-WUinstall -MicrosoftUpdate –ListOnly You get a warning: Can’t find registered service Microsoft Update. Use Get- WUServiceManager to get registered service. Manually: action1.com
  22. 22. 3. Get a List of Available Updates for the Computer To enable scanning on Microsoft Update, run the following command: Add-WUServiceManager -ServiceID "7971f918-a847-4430- 9279-4a52d1efe18d" -AddServiceFlag 7 Now you can perform a scan on Microsoft Update. Manually: action1.com
  23. 23. 3. Get a List of Available Updates for the Computer To remove certain products or specific packages from the list of updates your computer receives, you can exclude them by: - Categories (-NotCategory); - Name (-NotTitle); - Update number (-NotKBArticleID). For example, exclude from the list of updates for drivers, OneDrive, and one specific KB: Get-WUInstall -NotCategory "Drivers" -NotTitle OneDrive - NotKBArticleID KB4011670 -ListOnly Manually: action1.com
  24. 24. 4. Powershell Script to Install Windows Updates Remotely – PsWindowsUpdate To automatically download and install all available updates for your operating system, run:Get-WUInstall -AcceptAll – IgnoreReboot The AcceptAll key includes installation approval for all packages, and IgnoreReboot suppresses automatic restarts of Windows after installing updates. Manually: action1.com
  25. 25. 4. Powershell Script to Install Windows Updates Remotely – PsWindowsUpdate You can install only specific update packages: Get-WUInstall -KBArticleID KB4011670,KB4456655 –AcceptAll If you want to remove some updates from the installation list, run: Get-WUInstall -NotCategory "Drivers" -NotTitle OneDrive - NotKBArticleID KB4011670 -AcceptAll -IgnoreReboot Manually: action1.com
  26. 26. 4. Powershell Script to Install Windows Updates Remotely – PsWindowsUpdate To automate the installation of updates with exceptions on multiple computers, you can use the following script: PowerShell -ExecutionPolicy RemoteSigned -Command Import- Module PSWindowsUpdate; Get-WUInstall -NotCategory "Language packs" -NotTitle OneDrive -NotKBArticleID KB4011670 -AcceptAll –IgnoreReboot Manually: action1.com
  27. 27. 4. Powershell Script to Install Windows Updates Remotely – PsWindowsUpdate The module allows you to remotely start the installation of updates on several computers at once or on a server (the PSWindowsUpdate module should be present on the computers). The following command will install all available updates on three remote servers: Invoke-WUInstall -ComputerName server1, server2, server1-Script {ipmo PSWindowsUpdate; Get-WUInstall -AcceptAll -AutoReboot | Out-File C:WindowsPSWindowsUpdate.log } -Confirm:$false - Verbose -SkipModuleTest –RunNow Manually: action1.com
  28. 28. 5. View the History of Installed Updates Using the Get-WUHistory command, you can get a list of updates installed on your computer earlier. You can get information about the date of installation of a specific update:Get-WUHistory| Where-Object {$_.Title -match "KB4011*"} | Select-Object *|ft To obtain information about the presence of an installed update on several remote computers, you can use the following code: "server1","server2" | Get-WUHistory| Where-Object {$_.Title - match "KB4011634"} | Select-Object *|ft Manually: action1.com
  29. 29. 6. The Next Feature Is Uninstalling Updates To remove updates, use the Remove-WindowsUpdate cmdlet. You only need to specify the KB number as an argument to the KBArticleID parameter. To postpone the automatic restart of the computer, you can add the –NoRestart key:Remove- WindowsUpdate -KBArticleID KB4011634 -NoRestart Manually: action1.com
  30. 30. 7. How to Hide Unnecessary Updates Using Powershell You can hide certain updates so that they are never installed by Windows Update on your computer. For example, to hide the KB4011670 and KB4456655 updates, run the following commands:$HideList = "KB4011670", "KB4456655" Hide-WindowsUpdate -KBArticleID $HideList –Hide Manually: action1.com
  31. 31. 7. How to Hide Unnecessary Updates Using Powershell The next time you scan for updates using the Get-WUInstall – ListOnly command, hidden updates will not be displayed in the list of patches available for installation. You can list the updates that are hidden on this computer as follows: Get-WindowsUpdate -IsHidden To remove updates from hidden, run: Hide-WindowsUpdate -KBArticleID $HideList -Hide:$false Manually: action1.com
  32. 32. Other Relevant HOWTOs: How to Restart Remote Computer Free Tool: Install Patch Remotely Free Tool: Run Scheduled Task Remotely Free Tool: Set Share Permissions Free Tool: Web Browsers action1.com
  33. 33. Sign Up for Action1 • Instant sign-up • No phone calls to activate • Quick configuration Go to action1.com/free
  34. 34. Free Help • Call 1-346-444-8530 • action1.com/contact_us.html • Free technical support action1.com

Editor's Notes

  • Introducing Action One. Cloud-based endpoint security management.
  • To get started, just go to Action One dot com slash free, enter your email, confirm it and you are in. Basic configuration takes only a few minutes.
  • Feel free to call us or contact via Action One dot com. We can you help you to get started at absolutely no cost to you.
  • ×