Windows Updates PowerShell Code

title: ## Contents 
style: nestedList # TOC style (nestedList|inlineFirstLevel)
minLevel: 1 # Include headings from the specified level
maxLevel: 4 # Include headings up to the specified level
includeLinks: true # Make headings clickable
debugInConsole: false # Print debug info in Obsidian console

Overview

Sources:

  • **

Code Snippet

#Requires -RunAsAdministrator
 
# Transcript
$TranscriptFile = "$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-Scoop.log"
$TranscriptPath = Join-Path "$Env:TEMP\Scoop\$TranscriptFile"
Start-Transcript -Path $TranscriptPath -ErrorAction Ignore | Out-Null
 
# Execution Policy
Set-ExecutionPolicy Unrestricted -Scope CurrentUser
 
# PSWindowsUpdate
if (!(Get-PSResource -Name PSWindowsUpdate)) {
  Write-Verbose "Installing Module: PSWindowsUpdate..."
  Install-PSResource -Name PSWindowsUpdate -Scope CurrentUser -Force
  Import-Module PSWindowsUpdate
}
 
# Install Updates
Install-WindowsUpdate -MicrosoftUpdate -AcceptAll -IgnoreReboot -ForceInstall
 
# Restart
Write-Hose "Restarting Machine in 20 seconds..."
Start-Sleep -Seconds 20
Restart-Computer -Force

Details

About

This note is about …

See Also


Appendix

Note created on 2024-05-03 and last modified on 2024-05-03.

LIST FROM [[PowerShell - Windows Updates]] AND -"CHANGELOG" AND -"04-RESOURCES/Code/PowerShell/PowerShell - Windows Updates"

(c) No Clocks, LLC | 2024