I’ve been performing maintenance on my WSUS server the last couple of days. In particular, I’ve been trying to re-install a particular update that had previously been approved, then denied. This resulted in several hosts failing to properly re-install this update automatically forcing the need to manually re-install it; to 76 hosts. Nope!
Instead of going to each and every host, I turned to PowerShell. I’ve yet to enable PS remoting through the domain, so I used the venerable PsExec. (You can download PsExec from here: https://technet.microsoft.com/en-us/sysinternals/bb897553.aspx)
Now I have a tiny little snippet that will deploy a single Windows Update to several remote hosts in a single go, using PowerShell. Yes!
Here is the script:
$Hosts = Get-Content 'path/to/your/list/of/hosts.txt'
$hotfix = '//<server>/hotfix.msu'
$user = 'DOMAIN/Administrator'
$pass = 'your_super_secret_password'
$psexec = 'path/to/PsExec.exe'
foreach ($host in $Hosts.Trim()) {
& $psexec /accepteula //$host -u $user -p $pass -d wusa /install $hotfix /quiet /norestart
}
You’ll need to personalise the variables to your environment first. The .txt file is just a list of host names, with one host per line.
The script simply does the following. It iterates through your text file, and then runs PsExec on each host. PsExec run the Windows Update Standalone Installer (WUSA) and tells it to install your hotfix quietly and won’t restart the remote host.
The -d argument used on PsExec tells it to not wait for the process to finish. This allows you to install the update on several computers near asynchronously. There will be a wait though if PsExec cannot establish a connection to the computer. This could probably be fixed by using an if/else conditional using Test-Connection, but I wasn’t in a rush.
OH! One other thing. To deal with your more persistent errors, check the remote hosts’ Setup event log. WUSA’s errors are in decimal (ex. 2359302), convert them to HEX and look them up here: https://technet.microsoft.com/en-us/library/dd939837(WS.10).aspx. In this case the error 2359302 is 0x240006 (WU_S_ALREADY_INSTALLED).
Cheers!