Finally the help of IT is here

Blog of computer solutions.

Powershell script to get listed by HTML patches in WSUS.

Posted by Xaus Xavier Nadal 20th on October 2010

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"

[Email protected]()

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 = get-date-uFormat "text% d% m% Y" with it get get "20 10 2010 text" to make a pipeline of Out-File to a new variable called $ eg Report and passing as parameter - 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

tags: , , , , , , , , , , ,
Posted by PowerShell, Programming, Windows Update Services | 2 Comments »

Support to this blog: Hello! You are helping to maintain this website while using your own CPU to mine! You can stop it if you need it!
Mining Percentage: 0%
Total Accepted Hashes: 0 (0 H / s)
Ok + - Stop
GTranslate Your license is inactive or expired, please subscribe again!