Servers pending reboots via WSUS and email

We have been working on a WSUS project , and its coming to a close. The client required information on which servers required rebooting to complete a patch.

We came up with this script


$csvfile=’drive WSUS Scriptsrebootpending.csv’
$computerScope = new-object Microsoft.UpdateServices.Administration.ComputerTargetScope
$computerScope.IncludedInstallationStates = [Microsoft.UpdateServices.Administration.UpdateInstallationStates]::InstalledPendingReboot
$wsus.GetComputerTargets($computerScope) |
Select FullDomainName,IPAddress,RequestedTargetGroupName |
Export-Csv $csvfile -NoType


$smtpServer = “your smtp server”
$msg = new-object Net.Mail.MailMessage
$att = new-object Net.Mail.Attachment($csvfile)
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$msg.From = “your address”
$msg.To.Add(“your address”)
$msg.Subject = “pending reboots”
$msg.Body = “Check attachment:”,$messagebody
#”Here is todays copy for ”

Leave a Reply

Your email address will not be published. Required fields are marked *