Windows Update Agent force script, email results version 2.3 by -- Rob Dunn [WSUS MVP]
Rob Dunn [WSUS MVP] has created an excellent .vbs script (updatehf.vbs) which is very popular in WSUS Community. This script will do the following;
- Detects missing updates,
- Downloads approved updates which are missing,
- Installs the approved updates from WSUS Server,
- And reboots the computer after the updates are applied.
- Last but not the least; it can email a recipient the resulting log file.
Before you run this script, rename the downloaded script to updatehf.vbs and you need to edit some variables in the script;
MANDATORY VARIABLES
- sExePath - this is the location of the WindowsUpdateAgent20-x86.exe. Download it from http://go.microsoft.com/fwlink/?LinkId=43264. This script will install WindowsUpdateAgent20-x86.exe silently if it is required.
- strMailFrom - this is the email address used by the script to send the resulting log file to the intended recipient. (The Sender)
- strMailto - this is the recipient email address who will receive the resulting log file (The Recipient)
- strSMTPServer - this is the IP Address of the email server.
OPTIONAL VARIABLES
- Silent - 0 = verbose, 1 = silent (no windows or visible information)
- Intdebug - 0 = off, 1 = 1 (see some variables that are being passed)
- strAction - prompt|install|detect. Prompt gives users opportunity to install updates or not, install just installs them, detect updates the WU collection and downloads the updates (but does not install them) - useful if you want to have the computer refresh its stats to the stat server but not install the updates.
- blnEmail - 0 = off|1 = on. If set to 0, the script will not email a log file. If you specify an email address in the command-line, this will force the script to switch blnEmail to 1.
- strRestart - 0 = Do nothing|1 = restart|2 = shutdown. Command-switch restart: supersedes this variable.
If you don’t configure these optional variables, then you can manually input them from the command line.
Command line switches to run the script
- action: prompt|install|detect
- mode: silent|verbose
- email: you@yourdomain.com
- restart: 0 (do nothing)| 1 (restart) | 2 (shutdown)
- force: 0 (do not enforce restart action - this is optional, by default it is set to 0) | 1 (enforce restart action)
- emailsubject: Text for custom subject enclosed in quotations (i.e. "This is a custom subject") - (v2.2 and newer)
- fulldnsname: 0 (use non-qualified server name) | 1 (use fully qualified DNS name of the server that the script ran on) - (v2.2 and newer)
- emailifallok: 0 (don't email a report if there are no problems with the update process) | 1 (email report whether there are errors or not) - (v2.2 and newer)
- smtpserver: x.x.x.x or smtp mail hostname (define an alternate SMTP server) - (v2.2 and newer)
- logfile:"x:\path\log.txt" - (v2.3 and newer)
Note:
The command line switches will supersede the variables in the script.
Examples
- DETECT (interactive): updatehf.vbs action:detect mode:verbose email:you@yourdomain.com restart:0
- INSTALL (silently): updatehf.vbs action:install mode:silent email:you@yourdomain.com restart:1
- PROMPT: updatehf.vbs action:prompt mode:verbose email:you@yourdomain.com restart:1
Kudos to Rob and all those who have contributed. Once again thanks a lot Rob.
DOWNLOAD the latest version from http://www.vbshf.com/vbshf/forum/forums/thread-view.asp?tid=199&start=1 (current version 2.3)
See the changelog
If you have any issues/comments/bugs/suggestions or just want to say thanks to Rob, then reply to the on-going discussion on Windows Update Agent force script, email results version 2.3