Windows Update - Download modules and trigger run via PowerShell - superseded
Log In or Register to download the BES file, and more.

0 Votes


Description

This install the latest Windows updates.

Tested on Windows 10 v1709 with Powershell 5.1.  By the prerequisites mentioned, this will probably work on Windows 7+ and Server 2008 R2+ with PowerShell versions over 2.0.  If the module author hasn't updates his prerequisites, more likely to run on PS 3.0+.

  1. Checks for existing scripting policy LGPO registry item (cannot override GPO)
  2. If exists, back up and disable existing policy
  3. Install prerequisite: NuGet 2.8.5.201+
  4. Install Windows Update PowerShell Module v2.0.0.4 (tested, feel free to drop that requirement)
  5. Run Windows Update via newly added module
  6. (Optionally) Uninstall Windows Update PowerShell Module

It will not ask questions, and not provide options - it will simply install everything it is able to install in one round.

This version will NOT install Windows Feature Updates, such as Windows 10 version 1803.

Module Credit Michal Gajda, source: https://gallery.technet.microsoft.com/scriptcenter/2d191bcd-3308-4edd-9de2-88dff796b0bc/


Property Details

ID25522
StatusQA - Ready for Production Level Testing
TitleWindows Update - Download modules and trigger run via PowerShell
DomainBESC
SourceInternal
Source Release Date6/13/2018 12:00:00 AM
KeywordsWindows Update Powershell Module MichalGajda
Is TaskTrue
Added by on 6/13/2018 2:46:37 PM
Last Modified by on 6/13/2018 2:46:37 PM
Counters 449 Views / 0 Downloads
User Rating 1 star 2 star 3 star 4 star 5 star * Average over 0 ratings. ** Log In or Register to add your rating.

Relevance

isWindows (Relevance 1172)
Used in 1112 fixlets and 524 analyses   * Results in a true/false
Show indented relevance
windows of operating system

Actions

Action 1 (default)

Action Link Click here to deploy this action.
Script Type BigFix Action Script
// Set Powershell
parameter "PowerShellexe"="{value "Path" of key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell" of x64 registry}"
// Disable script protection
if {exist (value "EnableScripts" of it = "0") of key "HKLM\Software\Policies\Microsoft\Windows\PowerShell" of native registry}
wait cmd /c reg delete "HKLM\Software\Policies\Microsoft\Windows\PowerShell" /v "EnableScripts" /f
wait cmd /c reg add "HKLM\Software\Policies\Microsoft\Windows\PowerShell" /v "EnableScriptsBackup" /t REG_DWORD /d 00000001 /f
endif

// Install PowerShell Modules from PSGallery
waithidden "{parameter "PowerShellexe"}" -ExecutionPolicy Bypass -Command "Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force"
waithidden "{parameter "PowerShellexe"}" -ExecutionPolicy Bypass -Command "Install-Module -Name PSWindowsUpdate -RequiredVersion 2.0.0.4 -Force"
waithidden "{parameter "PowerShellexe"}" -ExecutionPolicy Bypass -Command "Import-Module -Name PSWindowsUpdate -Force"

// Check for and install Windows Updates
waithidden "{parameter "PowerShellexe"}" -ExecutionPolicy Bypass -Command "Get-WindowsUpdate -Install -MicrosoftUpdate -AcceptAll -Confirm:$false"

// Re-enable script protection
if {exist (value "EnableScriptsbackup" of it = "1") of key "HKLM\Software\Policies\Microsoft\Windows\PowerShell" of native registry}
wait cmd /c reg delete "HKLM\Software\Policies\Microsoft\Windows\PowerShell" /v "EnableScriptsBackup" /f
wait cmd /c reg add "HKLM\Software\Policies\Microsoft\Windows\PowerShell" /v "EnableScripts" /t REG_DWORD /d 00000000 /f
endif
Success Criteria

This action will be considered successful when the applicability relevance evaluates to false.


Sharing

Social Media:
Share this page on Yammer

Comments

Log In or Register to leave comments!