PowerShell Script to Query WSUS for Downloaded/Falied Patches on List of servers

Posted on: November 21, 2012

I work in a enviorment , where we patch our servers on Monthly basis . Post patching it is important for us to know about the server status , How many servers got patched , How many servers are still have the downloaded patches , How many serveers have failed to install the patches Etc.

I came up with an IDEA to write a PowerShell Script to get an overall Overview about this.

Below is the script which one can use to Accomplish the above task ,

Note – Before Running the script make sure you have created a C:\Names.txt file (List of servers goes here) against which you will query WSUS server to get the details.

$global:wsus = [Microsoft.UpdateServices.Administration.AdminProxy]::getUpdateServer(‘wsus ServerName Goes here’,$False,Port Number goes here of your WSUS)
$computerscope = New-Object Microsoft.UpdateServices.Administration.ComputerTargetScope
$updatescope = New-Object Microsoft.UpdateServices.Administration.UpdateScope
$s = Get-Content C:\Names.txt
$a = New-Object Microsoft.UpdateServices.Administration.ComputerTargetScope
$b = New-Object Microsoft.UpdateServices.Administration.UpdateScope
$c =  $wsus.getcomputertargets($a)
$id = @()
Foreach($Server in $s)
 $id += @($c | ? {$_.FulldomainName -like “$Server*”} | Select-Object -ExpandProperty ID)

$k = $wsus.GetSummariesPerComputerTarget($b,$a)
$k | Where-Object{$id -contains $_.ComputerTargetID} | ForEach {New-Object PSobject -Property @{
ComputerTarget = ($wsus.GetComputerTarget([guid]$_.ComputerTargetId)).FullDomainName
DownloadedCount = $_.DownloadedCount
FaliedCount = $_.FailedCount
}} | Export-Csv C:\PatchResult.csv -NoClobber -Force

Note –

$global:wsus = [Microsoft.UpdateServices.Administration.AdminProxy]::getUpdateServer(‘wsus ServerName Goes here’,$False,Port Number goes here of your WSUS)

You need to put WSUSServerName , If you are using SSL then Please put $TRUE , and If you are using any other port otherthan 80 , then put the appropriate port ,. If you are using Default port please let it blank

script will produce C:\PatchResult.csv which contains all the required information.

Hope this will help when it comes to patching 🙂

Happy Scripting.



Reference –


9 Responses to "PowerShell Script to Query WSUS for Downloaded/Falied Patches on List of servers"

Thank you for sharing your thoughts. I truly appreciate your
efforts and I am waiting for your further
post thank you once again.

I can’t remember the last time I really enjoyed an article
just as much as this one. You have gone beyond my expectations on this subject as
well as I agree with your points. You’ve done well with this.

I do trust all of the ideas you have presented for your post.
They’re very convincing and will definitely work. Nonetheless, the posts are very short for novices. Could you please lengthen them a bit from subsequent time? Thank you for the post.

I was wondering if you ever considered changing the
layout of your blog? Its very well written; I love what youve got to say.
But maybe you could a little more in the way of content so people could connect with
it better. Youve got an awful lot of text for only having
1 or 2 pictures. Maybe you could space it out better?

Hi there, I want to subscribe for this webpage to get
newest updates, therefore where can i do it please assist.

Spot on with this write-up, I seriously believe that this web site needs a lot more attention.

I’ll probably be back again to read through more, thanks for the info!

Way cool! Some extremely valid points! I appreciate you penning
this post and also the rest of the site is also
really good.

lne interesy. Razu jednego Przynęcająca projektowanie architektoniczne pdf.

wmawiał osobiście, że owo nabieranie.
Frodo wystrój ogrodów syknął z bólu. Pozyskał zbyt dużo ziemi, chciał
wypełnić jeszczze pobieżne
wgniecenie, które wykiełkowało w trakcie udeptywania. Wsza ponaciągane
mięśnie odmówiły
posłuszeństwa, trzonek skręcił się w dłoniach.
Niziołek odrzucił łopatę, zaczął
rozcierać przedramię.
– Co otóż to stoisz! – warknął. – Co, zatkało? Mi.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: