Windows Update Module - Get-wulist script problem

Hi All,

I have been playing with the PSWindowsUpdate module and have come out with the below script. It works well and sends me an emails with the an attached copy of updates available on each server. However, it seems that if one of the servers doesn’t require any updates, the HTML report comes back blank. Does anyone have any ideas on this?

` $Subject = “Server Updates as of $(Get-Date)”
$Attachment = “C:\Powershell\ServerUpdates\AvailableUpdates.htm”
$Body = “Please see attached the latest Server updates”

Measure how long it takes to run the script

$StartDTM = (get-date)

Import the Update Module

ipmo ‘\ServerShare\SCRIPTS$\PSWindowsUpdate’

$Servers = (Get-Content “C:\Powershell\ServerUpdates\test.txt”)

#embed a stylesheet in the html header
$head = @"

body { background-color:#dddddd;
font-size:12pt; }
td, th { border:1px solid black;
border-collapse:collapse; }
th { color:white;
background-color:black; }
table, tr, td, th { padding: 2px; margin: 0px }
table { margin-left:50px; }


$Fragment = " Required Server Updates $(Get-Date) "

$Updates = Get-WUList -ComputerName $Servers

group data by KB Number

$Groups=$Updates | Group-Object -Property KB

Check Updates for each server

ForEach ($Update in $Groups) {

define a collection of Updates from the group object


create an html fragment

$Fragment += $KB | Select-Object -Property ComputerName,KB,Status,Title,Size | ConvertTo-HTML -Fragment -As Table | Out-String

$EndDTM = (Get-Date)

$Footer=(“Elapsed Time: $(($endDTM-$startDTM).totalseconds) seconds”)

ConvertTo-Html -head $head -body $Fragment | Out-File C:\Powershell\ServerUpdates\AvailableUpdates.htm

Send-MailMessage -SmtpServer ServerFQDN -From -Subject $Subject -To -Attachments $Attachment -Body $Body -BodyAsHtml

I would say you’d want to look at this line specifically:

$Updates = Get-WUList -ComputerName $Servers

When one of the servers has no updates, if you were to set your variable for $servers and then just run the above line to Get-WUList from $servers, does $Updates end up having any data in it or does it receive an error or end up otherwise blank?


Hi Brian,

Thanks for the reply. No error message is given. The report generated has the title, but no contents, regardless of there being subsequent servers queried that are known to require updates.

OK, I think I have gotten around this. Thanks Brian for putting me on the right track.

I have added an IF statement within the loop that will check if the $Update variable is null. If it is, it will append the report with a “Server does not require updates” statement.