Finally the help of IT is here

Blog of computer solutions.

How to list approved patches and necessary equipment WSUS in Powershell

Posted by Xaus Xavier Nadal 21st on October 2010

Good,

Today in Article Powershell script to get Listed below patches in WSUS I showed you a script that makes us a list of all the patches needed for equipment and today I show a small modification by Albert Fortes in the code that manages to get this same list but approved patches.

That is, a list of patches Approved needed.

With this we get to see the patches that are missing from the equipment and we have previously approved for distribution from wsus.

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

 

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

$ Computers = $ wsus.GetComputerTargets ()

$ Path = \ \

$ 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)

{

$ UpdateScope = new-object Microsoft.UpdateServices.Administration.UpdateScope;

$ UpdateScope.UpdateApprovalActions = [Microsoft.UpdateServices.Administration.UpdateApprovalActions] :: Install `

-Bor [Microsoft.UpdateServices.Administration.UpdateApprovalActions] :: Uninstall

 

$ UpdateSummary = $ {computer}. GetUpdateInstallationSummary ($ UpdateScope)

 

$ 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"

If you have any question please make a comment and I will solventaré delighted.

See you soon MegaCracks.

tags: , , , , , , , , , ,
Posted by PowerShell, Windows Update Services | 1 Comment »