Wednesday, February 13, 2013

Installing Microsoft Update Standalone Packages Silently

MSU file extention are used to install Microsoft KB Hot Fixes. This process usually
display a dialog box similar to the Windows Update install dialog when installing
and at the end sometimes a reboot is needed.

As they use the same switches as the existing Microsoft updates,
installing them silently is very straightforward.

They are processed by a command named WUSA.EXE (Windows Update Standalone Installer),
so a command-line would look like this:


Where 6.0 is the OS version



You can run the WUSA command with /? to see a dialog box detailing the complete
help text:


wusa [/quiet] [/norestart]

/?, /h, /help – Display help information.

update – Full path of the MSU file.

/quiet – Quiet mode, no user interaction. reboot as needed

/norestart – When combined with /quiet, installer will NOT initiate reboot.
It is ignored if it is used alone

The following PowrShell Script will push a HOT FIX to a list of SERVERS

$Servers = $(1..176 | foreach {"SERVER$_"})

$HotfixPath = '\\Fileserver\Hotfixes\KB2464876\Windows6.0-KB2464876-x86.msu'

foreach ($Server in $Servers){
if (Test-Path "\\$Server\c$\Temp"){
Write-Host "Processing $Server..."
# Copy update package to local folder on server
Copy-Item $Hotfixpath "\\$Server\c$\Temp"
# Run command as SYSTEM via PsExec (-s switch)
& E:\SysinternalsSuite\PsExec -s \\$Server wusa C:\Temp\Windows6.0-KB2464876-x86.msu /quiet /norestart
if ($LastExitCode -eq 3010) {
$ConfirmReboot = $False
} else {
$ConfirmReboot = $True
# Delete local copy of update package
Remove-Item "\\$Server\c$\Temp\Windows6.0-KB2464876-x86.msu"
Write-Host "Restarting $Server..."
Restart-Computer -ComputerName $Server -Force -Confirm:$ConfirmReboot
} else {
Write-Host "Folder C:\Temp does not exist on the target server"

No comments: