-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOffline_WU.ps1
26 lines (20 loc) · 1.08 KB
/
Offline_WU.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# Check for elevation
if (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
Write-Output "This script requires elevation. Restarting as Administrator..."
Start-Process PowerShell.exe -Verb RunAs -ArgumentList "-NoExit","-File",$MyInvocation.MyCommand.Path
exit
}
# Get the directory where the script is located
$scriptDirectory = Split-Path -Parent $MyInvocation.MyCommand.Definition
# Find all .msu (Microsoft Update Standalone) files in the script directory
$updateFiles = Get-ChildItem $scriptDirectory -Filter "*.msu"
Write-Output "Starting Windows Update installation at $(Get-Date)"
# Install each update file
foreach ($updateFile in $updateFiles) {
Write-Output "Installing update: $($updateFile.Name)"
# Run the update installer silently with no restart
Start-Process -FilePath "wusa.exe" "$($updateFile.FullName) /quiet /norestart" -Wait
}
Write-Output "Update script completed at $(Get-Date)"
Write-Host "Press Enter to close this window..."
Read-Host