Finally the help of IT is here

Blog of computer solutions.

Powershell script to get listed by HTML patches in WSUS.

Written by Xaus Xavier Nadal on October 20th, 2010

Save pagePDF pageemail pagePrint page

Go longest title not ???.

Here you have a script created by Albert Fortes and modified by me that does the following:

This script is connected locally to our WSUS server and performs a query and a sum of the result of NotInstalled patches, and Failed Downloaded from each team and generates a .html file with the team name, patches sorted by the result of required patches and last contact and stores it in a file called ReportWsus_dia_mes_año_NombredeServidor.html located in a network folder that you indicate in the variable $ path.

The script is as follows:

[Reflection.assembly] :: LoadWithPartialName ( "Microsoft.UpdateServices.Administration")

 

$ Wsus = [Microsoft.UpdateServices.Administration.AdminProxy] :: GetUpdateServer ( "localhost", $ false);

$ Computers = $ wsus.GetComputerTargets ()

$ Path =\\ <Servidor_donde_guardar_el_report>

$ Computername =gc env: computername

$ FileOutput =get-date -uformat "ReportWsus_% d_% m_% Y_ $ computername.html"

$ Report = @ ()

Total = $ $ Computers.Count

$ I = 0

 

clear host

 

foreach ($ computer in $ Computers)

{

$ UpdateSummary = $ {computer} .GetUpdateInstallationSummary ()

$ Count = $ UpdateSummary.NotInstalledCount + $ UpdateSummary.DownloadedCount + $ UpdateSummary.FailedCount

$ Report_element = new-object psobject

$ Report_element | add-member NoteProperty "Computer" $ {computer} .FullDomainName

$ Report_element | add-member NoteProperty "NeededUpdates" $ Count

$ Report_element | add-member NoteProperty "LastUpdateSync" $ {computer} .LastSyncTime.ToString ()

$ Report + = $ Report_element

$ I = $ i + 1

$ Percent = ($ i / $ Total * 100)

Write-Progress -Activity "WSUS query ..." `

-Status "Wait a little more." -CurrentOperation ( "Complete $ i / total $") -PercentComplete ($ i / $ Total * 100)

}

 

Clear host

 

$ Report | sort NeededUpdates | ConvertTo-Html | Out-File -FilePath "$ Path $ FileOutput"

This script can save it in a file . Ps1 within the WSUS server and run from powershell. You can even create a scheduled task to run this program and generate the file on a network path every day for your security team can have a report where you can see how many teams are missing patches.

Curiosities of the script:

How to get the computer code in powershell ?: Use the command gc env: computername

 

How to create a file with the formatted date?: $ FileOutput -uformat = get-date "text% d% m% Y" get with it get "text 20 10 2010" to make a pipeline of Out-File to a new variable called $ such as parameter passing and Report - FilePath "$ FileOutput" get to have a file formatted as we want.

If you have any problem or something you doubt please send me a comment and I solventaré enchanted.

See you soon MegaCracks

Related Posts Plugin for WordPress, Blogger ...
Tags: , , , , , , , , , , ,


2 Responses to "Powershell Script to get list for HTML patches in WSUS."

  1. austin Says:

    it does not work I get this error Missing expression after unary operator '-'.
    At C: \ Documents and Settings \ adminsmb \ ps1.ps1: char 51: 3
    + - <<<< Status "Wait a little longer." -CurrentOperation ( "Complete $ i / total $") -PercentComplete ($ i / $ Total * 100)
    + CategoryInfo: ParserError: (-: String) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId: MissingExpressionAfterOperator

    I'm going crazy

  2. Leandro Says:

    I do not care that Austin ....

    =(

Leave a Reply

XHTML: You can use in Original tags: <a href="" title=""> <abbr title = ""> <acronym title = ""> <b> <blockquote cite = ""> <cite> <code> <del datetime = ""> <em> <i> <q cite = ""> <s> <strike> <strong>